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

Owner: Nobody
Requestors: hmbrand <h.m.brand [at] xs4all.nl>
Cc:
AdminCc:

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



Subject: bitwise shift is inconsistent on int
Download (untitled) / with headers
text/plain 1.5k
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 16' -9223372036854775808 -140737488355328 $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 32' -9223372036854775808 -2147483648 $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 63' -9223372036854775808 -1 $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 64' -9223372036854775808 -9223372036854775808 <===== plain wrong $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -32' -9223372036854775808 -39614081257132168796771975168 $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -64' -9223372036854775808 -170141183460469231731687303715884105728 $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 16' 9223372036854775807 140737488355327 $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 32' 9223372036854775807 2147483647 $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 63' 9223372036854775807 0 $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 64' 9223372036854775807 9223372036854775807 <= PLAIN WRONG $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -2' 9223372036854775807 36893488147419103228 $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -32' 9223372036854775807 39614081257132168792477007872 $ perl6 -e'my int $i = int.Range.max; say $i; say $i +< 2' 9223372036854775807 -4 <= WHAT? $ perl6 -e'my int $i = int.Range.max; say $i; say $i +< -2' 9223372036854775807 2305843009213693951
Plain-wrongs and WHATs print different results today. Bisectable points at https://github.com/rakudo/rakudo/commit/242baf256a210f1cb643cb6324916dbc76184c9f

I think we now only need tests for this ticket.

On 2015-06-23 09:05:43, hmbrand wrote:
Show quoted text
> $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 16'
> -9223372036854775808
> -140737488355328
> $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 32'
> -9223372036854775808
> -2147483648
> $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 63'
> -9223372036854775808
> -1
> $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 64'
> -9223372036854775808
> -9223372036854775808 <=====
> plain wrong
> $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -32'
> -9223372036854775808
> -39614081257132168796771975168
> $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -64'
> -9223372036854775808
> -170141183460469231731687303715884105728
>
> $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 16'
> 9223372036854775807
> 140737488355327
> $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 32'
> 9223372036854775807
> 2147483647
> $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 63'
> 9223372036854775807
> 0
> $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 64'
> 9223372036854775807
> 9223372036854775807 <=
> PLAIN WRONG
> $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -2'
> 9223372036854775807
> 36893488147419103228
> $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -32'
> 9223372036854775807
> 39614081257132168792477007872
> $ perl6 -e'my int $i = int.Range.max; say $i; say $i +< 2'
> 9223372036854775807
> -4 <=
> WHAT?
> $ perl6 -e'my int $i = int.Range.max; say $i; say $i +< -2'
> 9223372036854775807
> 2305843009213693951


RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 2.1k
On Sun, 17 Sep 2017 15:17:47 -0700, alex.jakimenko@gmail.com wrote: Show quoted text
> Plain-wrongs and WHATs print different results today. Bisectable > points at > https://github.com/rakudo/rakudo/commit/242baf256a210f1cb643cb6324916dbc76184c9f > > I think we now only need tests for this ticket. > > On 2015-06-23 09:05:43, hmbrand wrote:
> > $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 16' > > -9223372036854775808 > > -140737488355328 > > $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 32' > > -9223372036854775808 > > -2147483648 > > $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 63' > > -9223372036854775808 > > -1 > > $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 64' > > -9223372036854775808 > > -9223372036854775808 <===== > > plain wrong > > $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -32' > > -9223372036854775808 > > -39614081257132168796771975168 > > $ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -64' > > -9223372036854775808 > > -170141183460469231731687303715884105728 > > > > $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 16' > > 9223372036854775807 > > 140737488355327 > > $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 32' > > 9223372036854775807 > > 2147483647 > > $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 63' > > 9223372036854775807 > > 0 > > $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 64' > > 9223372036854775807 > > 9223372036854775807 <= > > PLAIN WRONG > > $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -2' > > 9223372036854775807 > > 36893488147419103228 > > $ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -32' > > 9223372036854775807 > > 39614081257132168792477007872 > > $ perl6 -e'my int $i = int.Range.max; say $i; say $i +< 2' > > 9223372036854775807 > > -4 <= > > WHAT? > > $ perl6 -e'my int $i = int.Range.max; say $i; say $i +< -2' > > 9223372036854775807 > > 2305843009213693951
For some of these that OP pointed out as questionable I get the same results as in C. For others, the bug still exists, where it just returns an Int instead of overflowing: https://irclog.perlgeek.de/perl6/2017-10-08#i_15272553
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 233b
Tests were added in https://github.com/perl6/roast/pull/344/files There are three fudges where it's unknown what the proper behaviour should be (overflow or switch to Int?). Someone Who Knows should review them and unfudge/correct.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 522b
On Sat, 07 Oct 2017 23:35:26 -0700, cpan@zoffix.com wrote: Show quoted text
> Tests were added in https://github.com/perl6/roast/pull/344/files > > There are three fudges where it's unknown what the proper behaviour > should be (overflow or switch to Int?). > > Someone Who Knows should review them and unfudge/correct.
Some comments on this: https://irclog.perlgeek.de/perl6-dev/2018-03-05#i_15887265 * TimToady thinks people who are writing crypto codes want ways to keep everything native, if we make it default the other way


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