Skip Menu |
Report information
Id: 126943
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: zefram [at] fysh.org
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] errors for large left shifts
From: Zefram <zefram [...] fysh.org>
Date: Thu, 17 Dec 2015 02:48:12 +0000
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 476b
When shifting a non-zero integer left by a very large amount, generally some kind of error should result, such as memory exhaustion. But for some values Rakudo is producing silly small outputs: Show quoted text
> 123 +< (1 +< 31)
8863084066665136128 Show quoted text
> 123 +< ((1 +< 31) + 1)
17726168133330272256 Show quoted text
> 123 +< ((1 +< 32) - 1)
0 Show quoted text
> 123 +< (1 +< 32)
123 Show quoted text
> 123 +< ((1 +< 32) + 1)
246 Show quoted text
> 123 +< ((1 +< 33) - 1)
0 Show quoted text
> 123 +< (1 +< 33)
123 Show quoted text
> 123 +< ((1 +< 33) + 1)
246 Show quoted text
> 123 +< ((1 +< 64) - 1)
61 -zefram
To: "Zefram (via RT)" <perl6-bugs-followup [...] perl.org>
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Subject: Re: [perl #126943] [BUG] errors for large left shifts
Date: Thu, 17 Dec 2015 11:15:18 +0100
Show quoted text
> On 17 Dec 2015, at 03:48, Zefram (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Zefram > # Please include the string: [perl #126943] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=126943 > > > > When shifting a non-zero integer left by a very large amount, generally > some kind of error should result, such as memory exhaustion. But for > some values Rakudo is producing silly small outputs: >
>> 123 +< (1 +< 31)
> 8863084066665136128
>> 123 +< ((1 +< 31) + 1)
> 17726168133330272256
>> 123 +< ((1 +< 32) - 1)
> 0
>> 123 +< (1 +< 32)
> 123
>> 123 +< ((1 +< 32) + 1)
> 246
>> 123 +< ((1 +< 33) - 1)
> 0
>> 123 +< (1 +< 33)
> 123
>> 123 +< ((1 +< 33) + 1)
> 246
>> 123 +< ((1 +< 64) - 1)
> 61
As with #126941, commit f6091476486d29c8886d gives this a slightly better error message, at least until 6.c. $ 6 'say 123 +< ((1 +< 32) - 1)' Big integer 4294967295 not yet supported on righthand side of '+<' operator Liz
From: Zefram <zefram [...] fysh.org>
To: Elizabeth Mattijsen via RT <perl6-bugs-followup [...] perl.org>
Date: Thu, 17 Dec 2015 10:31:24 +0000
Subject: Re: [perl #126943] [BUG] errors for large left shifts
Download (untitled) / with headers
text/plain 1010b
Elizabeth Mattijsen via RT wrote: Show quoted text
>As with #126941, commit f6091476486d29c8886d gives this a slightly >better error message, at least until 6.c.
Providing any error here, rather than a wrong answer, resolves this issue. At least it does so for the cases with a non-zero lhs, for which the correct answer can't be represented. In the exception where the lhs is zero, formerly shift distances up to ((1 +< 64) - 1) were accepted, and it's a shame to reduce that range. But either way that range being limited is LTA in a manner exactly akin to [perl #126941]. That ought to be addressed as an extension of that ticket or as a separate issue. Since you've raised the question of pre-xmas vs post-xmas, I think the only one of these bit-shift tickets that could possibly be a pre-xmas priority is [perl #126942]. Not because it has any deep implications, but just because the lower end of its misbehaviour is reachable with reasonable inputs that are fairly likely to arise in substantive programs. -zefram


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org