Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"splice() offset past end of array" warning doesn't always appear #12927

Closed
p5pRT opened this issue Apr 23, 2013 · 9 comments
Closed

"splice() offset past end of array" warning doesn't always appear #12927

p5pRT opened this issue Apr 23, 2013 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 23, 2013

Migrated from rt.perl.org#117729 (status was 'resolved')

Searchable as RT117729$

@p5pRT
Copy link
Author

p5pRT commented Apr 23, 2013

From @karenetheridge

According to the splice documentation in perlfunc​:

  splice ARRAY or EXPR,OFFSET

  If OFFSET is past the end of the array, Perl issues a warning, and
  splices at the end of the array.

Consider​:
  perl -wle'use warnings FATAL => "all"; my @​arr = qw(0 .. 10); splice(@​arr, 20); print "ar is @​arr"'

This generates a warning on some versions/architectures and not others.
Based on the versions tested, this appears to have regressed between 5.14.3
and 5.16.0.

warning​:
5.8.9 darwin OSX 10.6.8
5.14.2 darwin OSX 10.6.8
5.14.3 darwin OSX 10.6.8
5.14.3 linux CentOS

no warning​:
5.16.0 linux ubuntu
5.16.0 darwin OSX 10.6.8
5.16.1 darwin OSX 10.6.8
5.16.3 darwin OSX 10.6.8
5.17.11 darwin OSX 10.6.8

@p5pRT
Copy link
Author

p5pRT commented Apr 24, 2013

From @jkeenan

On Tue Apr 23 13​:14​:02 2013, perl@​froods.org wrote​:

According to the splice documentation in perlfunc​:

splice ARRAY or EXPR,OFFSET

If OFFSET is past the end of the array, Perl issues a warning, and
splices at the end of the array.

Consider​:
perl -wle'use warnings FATAL => "all"; my @​arr = qw(0 .. 10);
splice(@​arr, 20); print "ar is @​arr"'

This generates a warning on some versions/architectures and not
others.
Based on the versions tested, this appears to have regressed between
5.14.3
and 5.16.0.

warning​:
5.8.9 darwin OSX 10.6.8
5.14.2 darwin OSX 10.6.8
5.14.3 darwin OSX 10.6.8
5.14.3 linux CentOS

no warning​:
5.16.0 linux ubuntu
5.16.0 darwin OSX 10.6.8
5.16.1 darwin OSX 10.6.8
5.16.3 darwin OSX 10.6.8
5.17.11 darwin OSX 10.6.8

Confirmed to occur in blead as well.

@p5pRT
Copy link
Author

p5pRT commented Apr 24, 2013

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Apr 24, 2013

From @ikegami

It's not a regression; it's an intentional change.

C<< splice(@​a, $n) >> is commonly used to truncate an array if it's too
large, so C<< splice(@​a, $n) >> (with no further args) does not warn even
if @​a<$n.

See
https://rt-archive.perl.org/perl5/Public/Bug/Display.html?id=78462
http​://perl5.git.perl.org/perl.git/commitdiff/5cd408a276e19848774860967c3ec06b67b863ee?hp=0890f1a536cff0aff68038cae78e02c9d9b6a2b2

So, this is merely a documentation bug for which I'll submit a patch
tomorrow.

- Eric

On Tue, Apr 23, 2013 at 8​:34 PM, James E Keenan via RT <
perlbug-followup@​perl.org> wrote​:

On Tue Apr 23 13​:14​:02 2013, perl@​froods.org wrote​:

According to the splice documentation in perlfunc​:

splice ARRAY or EXPR,OFFSET

If OFFSET is past the end of the array, Perl issues a warning, and
splices at the end of the array.

Consider​:
perl -wle'use warnings FATAL => "all"; my @​arr = qw(0 .. 10);
splice(@​arr, 20); print "ar is @​arr"'

This generates a warning on some versions/architectures and not
others.
Based on the versions tested, this appears to have regressed between
5.14.3
and 5.16.0.

warning​:
5.8.9 darwin OSX 10.6.8
5.14.2 darwin OSX 10.6.8
5.14.3 darwin OSX 10.6.8
5.14.3 linux CentOS

no warning​:
5.16.0 linux ubuntu
5.16.0 darwin OSX 10.6.8
5.16.1 darwin OSX 10.6.8
5.16.3 darwin OSX 10.6.8
5.17.11 darwin OSX 10.6.8

Confirmed to occur in blead as well.

---
via perlbug​: queue​: perl5 status​: new
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=117729

@p5pRT
Copy link
Author

p5pRT commented Apr 24, 2013

From @karenetheridge

On Tue, Apr 23, 2013 at 09​:52​:07PM -0700, Eric Brine via RT wrote​:

It's not a regression; it's an intentional change.

C<< splice(@​a, $n) >> is commonly used to truncate an array if it's too
large, so C<< splice(@​a, $n) >> (with no further args) does not warn even
if @​a<$n.

This is quite reasonable (and indeed, this is the exact usecase where I
discovered that there was a warning on my not-quite-as-current production
system). :)

So, this is merely a documentation bug for which I'll submit a patch
tomorrow.

Thanks! (Was there also a perldelta entry for this? it's not too late to
put one in perldelta5160.)

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2013

From @ikegami

On Wed, Apr 24, 2013 at 10​:47 AM, Karen Etheridge <perl@​froods.org> wrote​:

On Tue, Apr 23, 2013 at 09​:52​:07PM -0700, Eric Brine via RT wrote​:

So, this is merely a documentation bug for which I'll submit a patch

tomorrow.

Thanks! (Was there also a perldelta entry for this? it's not too late to

put one in perldelta5160.)

Patched attached. Ok, it's not "tomorrow", but I figured I'd wait til 5.18
was out.

It actually is too late to add to perldelta5160, but it was actually
mentioned.

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2013

From @ikegami

0001-Adjust-documentation-for-removal-of-splice-warning.patch
From b4f8845653bc5261c5f8827c3edad6747396b651 Mon Sep 17 00:00:00 2001
From: Eric Brine <ikegami@adaelis.com>
Date: Sun, 2 Jun 2013 21:46:07 -0700
Subject: [PATCH] Adjust documentation for removal of splice warning

---
 pod/perlfunc.pod |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 5c6b4f8..3b36873 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -6766,8 +6766,8 @@ If LENGTH is omitted, removes everything from OFFSET onward.
 If LENGTH is negative, removes the elements from OFFSET onward
 except for -LENGTH elements at the end of the array.
 If both OFFSET and LENGTH are omitted, removes everything.  If OFFSET is
-past the end of the array, Perl issues a warning, and splices at the
-end of the array.
+past the end of the array and a LENGTH was provided, Perl issues a warning,
+and splices at the end of the array.
 
 The following equivalences hold (assuming C<< $#a >= $i >> )
 
-- 
1.7.2.5

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2013

From @cpansprout

On Sun Jun 02 21​:44​:25 2013, ikegami@​adaelis.com wrote​:

On Wed, Apr 24, 2013 at 10​:47 AM, Karen Etheridge <perl@​froods.org> wrote​:

On Tue, Apr 23, 2013 at 09​:52​:07PM -0700, Eric Brine via RT wrote​:

So, this is merely a documentation bug for which I'll submit a patch

tomorrow.

Thanks! (Was there also a perldelta entry for this? it's not too
late to

put one in perldelta5160.)

Patched attached. Ok, it's not "tomorrow", but I figured I'd wait til 5.18
was out.

Thank you. Applied as 8e602cc.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2013

@cpansprout - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant