diff options
author | Karl Williamson <khw@cpan.org> | 2021-03-15 21:01:47 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-03-29 08:53:34 -0600 |
commit | 4e82c85b1c9c9b30253b8624470da6f20a6c0604 (patch) | |
tree | dfecf8b7e83c6ca2c6d585633df848797a435e11 /t | |
parent | e7ba8cfdf9fb07ab6669c58b380241e480711c01 (diff) | |
download | perl-4e82c85b1c9c9b30253b8624470da6f20a6c0604.tar.gz |
Fix broken left shift of IV_MIN under 'use integer'
This fixes GH 18639
When I wrote this code, I conflated casting and complementing.
Diffstat (limited to 't')
-rw-r--r-- | t/op/bop.t | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/t/op/bop.t b/t/op/bop.t index 07f057d0a9..31b6531a03 100644 --- a/t/op/bop.t +++ b/t/op/bop.t @@ -18,7 +18,7 @@ BEGIN { # If you find tests are failing, please try adding names to tests to track # down where the failure is, and supply your new names as a patch. # (Just-in-time test naming) -plan tests => 502; +plan tests => 503; # numerics ok ((0xdead & 0xbeef) == 0x9ead); @@ -33,6 +33,13 @@ ok ((33023 >> 7) == 257); # signed vs. unsigned ok ((~0 > 0 && do { use integer; ~0 } == -1)); +{ # GH #18639 + my $iv_min = -(~0 >> 1) - 1; + my $shifted; + { use integer; $shifted = $iv_min << 0 }; + is($shifted, $iv_min, "IV_MIN << 0 yields IV_MIN under 'use integer'"); +} + my $bits = 0; for (my $i = ~0; $i; $i >>= 1) { ++$bits; } my $cusp = 1 << ($bits - 1); |