[Nix-dev] Re: [Nix-commits] SVN commit: nix - 13888 - eelco - in nixpkgs/branches/stdenv-updates/pkgs: development/libraries/aterm top-level

Ludovic Courtès ludo at gnu.org
Tue Jan 27 19:32:08 CET 2009


Hi,

Eelco Dolstra <e.dolstra at tudelft.nl> writes:

> * A patch for compiling the ATerm library with GCC 4.3.  Without it,
>   the code for resizing ATerm tables gets stuck in an infinite loop
>   (http://bugzilla.sen.cwi.nl:8080/show_bug.cgi?id=841).  The problem
>   is in this bit of code in hash.c, which tries to dynamically figure
>   out the maximum signed integer:
>
>     long try_long_max;
>     long long_max;
>     long delta;
>
>     try_long_max = 1;
>     do {
>       long_max = try_long_max;
>       try_long_max = long_max * 2;
>     } while (try_long_max > 0);
>
>   At -O2, GCC 4.3 determines that 1 * 2 * 2 * ... can never be <= 0,
>   and so it optimises this into a 1-instruction infinite loop:
>
>     0x0805a782 <keyPut+1282>: jmp  0x805a782 <keyPut+1282>
>
>   Quite beautiful really. ;-)

Such hacks are bound to fail, per ANSI C, which does not define the
behavior resulting from signed arithmetic overflow.  See the GCC doc for
`-fstrict-overflow' (info "(gcc) Optimize Options").

Thanks,
Ludo'.



More information about the nix-dev mailing list