O2 and Overflow

2010-04-23 Thread Heinz Riener
Dear all, 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

Re: O2 and Overflow

2010-04-23 Thread Heinz Riener
On 04/23/2010 07:35 PM, Andrew Pinski wrote: Sent from my iPhone On Apr 23, 2010, at 10:25 AM, Heinz Riener wrote: [...] Signed interger overflow is undefined. Use -fwrapv or -fno-strict-overflow if you want gcc to behave as signed interger overflow being defined. Yes, that's w