Skip Menu |
Report information
Id: 126940
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)



From: Zefram <zefram [...] fysh.org>
Date: Thu, 17 Dec 2015 02:34:19 +0000
To: rakudobug [...] perl.org
Subject: [BUG] errors for very large right shifts
Download (untitled) / with headers
text/plain 446b
It seems to be intended (though it's not documented) that long bit shifts produce the mathematically correct answer: Show quoted text
> 123 +> (1 +< 10)
0 but for some particularly large right shift distances, this doesn't work: Show quoted text
> 123 +> (1 +< 63)
123 Show quoted text
> 123 +> ((1 +< 64) - 100)
155921023828072216384094494261248 Show quoted text
> 123 +> ((1 +< 64) - 1)
246 Presumably these shift distance values are being subjected to some bitwise reinterpretation after unboxing. -zefram
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Wed, 16 Dec 2015 18:34:42 -0800, zefram@fysh.org wrote: Show quoted text
> It seems to be intended (though it's not documented) that long bit shifts > produce the mathematically correct answer: >
> > 123 +> (1 +< 10)
> 0 > > but for some particularly large right shift distances, this doesn't work: >
> > 123 +> (1 +< 63)
> 123
> > 123 +> ((1 +< 64) - 100)
> 155921023828072216384094494261248
> > 123 +> ((1 +< 64) - 1)
> 246 > > Presumably these shift distance values are being subjected to some > bitwise reinterpretation after unboxing. > > -zefram
For record, all three of the problematic ones now throw. Is that the desired behaviour? <Zoffix__> m: say 123 +> ((1 +< 64) - 100) <camelia> rakudo-moar 8efffb: OUTPUT: «Cannot unbox 64 bit wide bigint into native integer␤ in block <unit> at <tmp> line 1␤␤» <Zoffix__> m: say 123 +> ((1 +< 64) - 1) <camelia> rakudo-moar 8efffb: OUTPUT: «Cannot unbox 64 bit wide bigint into native integer␤ in block <unit> at <tmp> line 1␤␤» <Zoffix__> m: say 123 +> (1 +< 63) <camelia> rakudo-moar 8efffb: OUTPUT: «Cannot unbox 64 bit wide bigint into native integer␤ in block <unit> at <tmp> line 1␤␤»
To: Zoffix Znet via RT <perl6-bugs-followup [...] perl.org>
Subject: Re: [perl #126940] [BUG] errors for very large right shifts
Date: Mon, 5 Jun 2017 21:22:53 +0100
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 715b
Zoffix Znet via RT wrote: Show quoted text
>For record, all three of the problematic ones now throw. Is that the >desired behaviour?
Not the desired behaviour, no. It's a massive improvement over giving the wrong answer, and arguably fixes the bug qua bug, but it's still less than awesome. It would be easy (and shouldn't even cause any loss of usual-case performance) to make these cases give the right answer. If the decision is for these cases throwing to be the final behaviour, then this limitation on the bit shift operators should be documented. (You don't need to specifically document that the operation will fail if the right answer is too big to represent, but in this case the right answer is very small.) -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