[redirect to gcc-help] On 04/23/2010 06:25 PM, Heinz Riener wrote: > I'm using the native GCC version[1] of my GNU/Linux distribution. I > wonder whether GCC's optimization behavior is in the following case > correct. Consider the following two programs: > > (1) > int test(int n) { > if (n > 0) > return 1; > return 0; > } > > (2) > int test(int n) { > if (2*n > 0) > return 1; > return 0; > } > > After compiling both with the flags '-c -O2 -pedantic -Wall', they > result in the same object file. I expected the object files to be > different. (The second program may overflow, the first program does > not.) If you have a look at the C standard, you'll see that signed integer overflow is undefined behaviour. Therefore, it's perfectly correct to ignore it. Andrew.