------- Comment #49 from ian at airs dot com 2007-01-22 20:16 ------- In the C language standard "undefined behaviour" meants that the compiler can do anything at all. It means that the program is specifically undefined.
When you say that the compiler should not eliminate the test because the value does turn out to be negative, you appear to be assuming that signed overflow is actually "implementation defined behaviour." That would have the property that you are after. When you say that -fwrapv makes the code faster, I don't know which benchmarks you are relying on. Other people have demonstrated that -fwrapv slows down the well-known SPEC benchmark. I've written some comments in the appropriate place: the gcc mailing list: http://gcc.gnu.org/ml/gcc/2007-01/msg00885.html -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475