A while back Tom Lane presented the potential problem with gcc signed
overflow handling, but now it's not just a theoretical problem.
http://archives.postgresql.org/pgsql-hackers/2005-12/msg00635.php
Gcc 4.3 has started to perform optimizations based on the denial of the
existence of signed overflow. Building CVS HEAD with gcc 4.3rc2 I get the
following warnings:
localtime.c:1223: warning: assuming signed overflow does not occur when
assuming that (X + c) < X is always false
localtime.c:1227: warning: assuming signed overflow does not occur when
assuming that (X - c) > X is always false
array_userfuncs.c:100: warning: assuming signed overflow does not occur
when assuming that (X - c) > X is always false
float.c:2696: warning: assuming signed overflow does not occur when
assuming that (X + c) < X is always false
float.c:2712: warning: assuming signed overflow does not occur when
assuming that (X + c) < X is always false
oracle_compat.c:1479: warning: assuming signed overflow does not occur
when assuming that (X + c) < X is always false
I don't understand the difference between -fwrapv and
-fno-strict-aliasing, but it seems we need at least one of them.
http://www.airs.com/blog/archives/120
Kris Jurka