develooper Front page | perl.perl5.porters | Postings from June 2015

Re: [perl #125510] Wrongly calculated $[-value with big numbers

Thread Previous
June 29, 2015 15:25
Re: [perl #125510] Wrongly calculated $[-value with big numbers
Message ID:
Norman Koch wrote:
>So, the array-counter seems to be a signed integer having an overflow
>here, right?

Yeah.  Its handling has always been quite crude, and setting it high
enough to invoke range errors is just asking for trouble.  The only
non-zero value you're ever expected to assign to it is 1.

>Also, every really big number, e.g. $[ = 10 ** 100000, just sets the
>variable to -1.

It's a native integer underneath, so your floating-point 10**100000
overflows on conversion, yielding MAX_UV, which coerces to IV -1.

Generally, we handle indices of all kinds as native integers, for which
range limits are visible.  It's not a bug that things fail when the
ranges are exceeded, and in particular not a bug that we don't handle
them as bignums.

>But then, please forgive me if this is not worth a bug-report.

This ticket should be closed as not-a-bug.  But you are not wrong to
have questioned it.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About