develooper Front page | perl.perl5.porters | Postings from July 2010

[perl #6021] += and ++ do different things under 'use integer'

From:
George Greer via RT
Date:
July 29, 2010 21:07
Subject:
[perl #6021] += and ++ do different things under 'use integer'
Message ID:
rt-3.6.HEAD-11314-1280462832-1115.6021-15-0@perl.org
On Tue Mar 13 00:39:47 2001, dhd@eradicator.org wrote:
> dhd@timebomb:~$ perl -v
> This is perl, v5.6.0 built for i386-linux
> dhd@timebomb:~$ perl -le 'use integer; $foo=0xffffffff; print $foo;
>    ++$foo; print $foo'
> 4294967295
> 4294967296
> dhd@timebomb:~$ perl -le 'use integer; $foo=0xffffffff; print $foo;
>    $foo += 1; print $foo'
> 4294967295
> 0
> 
> Looks to me like the pre/postincrement operators are not respecting
> the integer pragma.  This problem also exists in 5.005_03.

The consensus of this ticket was "not during maint" but that is years
ago so I thought I'd prod this back to attention.

DaveM also noted:
$ perl585 -le'use integer;print 0x7fffffff+1'
-2147483648

so it is already inconsistent.

One "solution" to the problem is everybody getting 64-bit machines:

$ ./perl -I lib -le 'use integer; $foo=0xffffffff; print $foo; $foo +=
1; print $foo'
4294967295
4294967296
$ ./perl -I lib -V:archname
archname='x86_64-linux';

This ticket also notable for having Nicholas Clark's nasal demons.

-- 
George Greer



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About