Skip Menu |

This queue is for tickets about the Math-Int128 CPAN distribution.

Report information
The Basics
Id: 86832
Status: resolved
Worked: 1.3 hours (80 min)
Priority: 0/
Queue: Math-Int128

People
Owner: Nobody in particular
Requestors: DROLSKY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.09



Subject: Bug with <<= and/or |=
The following code produces what seems to be an internally broken Math::UInt128 object: use strict; use warnings; use integer; use feature 'say'; use Math::Int128 qw( uint128 ); my $int = uint128(0); for my $n ( 0, 0, 255, 4294967295 ) { $int <<= 32; $int |= $n; } # This will either blow up or just give the wrong number say $int; But this code works: use strict; use warnings; use integer; use feature 'say'; use Math::Int128 qw( uint128 ); my $int = uint128(0); for my $n ( 0, 0, 255, 4294967295 ) { $int = ( $int << 32 ) | $n; } say $int; It seems like there's some sort of bug in "<<=" and/or "|=".
On Wed Jul 10 11:57:57 2013, DROLSKY wrote: Show quoted text
> The following code produces what seems to be an internally broken > Math::UInt128 object: > > use strict; > use warnings; > use integer; > > use feature 'say'; > > use Math::Int128 qw( uint128 ); > > my $int = uint128(0); > > for my $n ( 0, 0, 255, 4294967295 ) { > $int <<= 32; > $int |= $n; > } > > # This will either blow up or just give the wrong number
I have uploaded to CPAN a new version (0.09) that solves the "give the wrong number" part of the problem. I have been unable to make the program crash either with the new or the old version. It may be a compiler or OS dependant thing. In any case, I have changed most of the code supporting <<= so the problem may just go away. Otherwise, let me know which Perl, OS and gcc versions you are using.
On Thu Jul 11 09:11:34 2013, SALVA wrote: Show quoted text
> On Wed Jul 10 11:57:57 2013, DROLSKY wrote:
> > The following code produces what seems to be an internally broken > > Math::UInt128 object: > > > > use strict; > > use warnings; > > use integer; > > > > use feature 'say'; > > > > use Math::Int128 qw( uint128 ); > > > > my $int = uint128(0); > > > > for my $n ( 0, 0, 255, 4294967295 ) { > > $int <<= 32; > > $int |= $n; > > } > > > > # This will either blow up or just give the wrong number
> > I have uploaded to CPAN a new version (0.09) that solves the "give the > wrong number" part of the problem. > > I have been unable to make the program crash either with the new or > the old version. It may be a compiler or OS dependant thing. > > In any case, I have changed most of the code supporting <<= so the > problem may just go away. Otherwise, let me know which Perl, OS and > gcc versions you are using.
I marked this resolved too soon. Whatever you changed now causes a worse broken behavior where bit shifts are producing totally broken results. I'll come up with a script to reproduce this shortly.
On Tue Jul 16 18:09:43 2013, DROLSKY wrote: Show quoted text
> On Thu Jul 11 09:11:34 2013, SALVA wrote:
> > On Wed Jul 10 11:57:57 2013, DROLSKY wrote:
> > > The following code produces what seems to be an internally broken > > > Math::UInt128 object: > > > > > > use strict; > > > use warnings; > > > use integer; > > > > > > use feature 'say'; > > > > > > use Math::Int128 qw( uint128 ); > > > > > > my $int = uint128(0); > > > > > > for my $n ( 0, 0, 255, 4294967295 ) { > > > $int <<= 32; > > > $int |= $n; > > > } > > > > > > # This will either blow up or just give the wrong number
> > > > I have uploaded to CPAN a new version (0.09) that solves the "give
> the
> > wrong number" part of the problem. > > > > I have been unable to make the program crash either with the new or > > the old version. It may be a compiler or OS dependant thing. > > > > In any case, I have changed most of the code supporting <<= so the > > problem may just go away. Otherwise, let me know which Perl, OS and > > gcc versions you are using.
> > > I marked this resolved too soon. Whatever you changed now causes a > worse broken behavior where bit shifts are producing totally broken > results. I'll come up with a script to reproduce this shortly.
I have accepted your pull request at GitHub and released version 0.11. Thank you for looking into the problem and solving it.