develooper Front page | perl.perl5.porters | Postings from April 2013

Re: [perl #117729] "splice() offset past end of array" warningdoesn't always appear

Thread Previous | Thread Next
From:
Eric Brine
Date:
April 24, 2013 04:51
Subject:
Re: [perl #117729] "splice() offset past end of array" warningdoesn't always appear
Message ID:
CALJW-qH_zqpiPaxegUC0JCWgrFS5d1p7_q4HYUbBXs7NPmZiCw@mail.gmail.com
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.perl.org/rt3/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.perl.org:443/rt3/Ticket/Display.html?id=117729
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About