Chris Thiel wrote: > I have a question about some relational expressions being transformed > into constants when neither wrapping nor strict signed overflow is used. > Here is the example I was looking at: > > extern int get_int (void); > extern void foo (int); > > int > main (void) > { > int a = get_int (); > foo (a + 1 > a); > foo (a + 1 >= a); > foo (a + 1 == a); > foo (a + 1 <= a); > foo (a + 1 < a); > foo (a + 1 != a); > return 0; > } > > I was under the impression that none of these would be simplified into > constants when using `-fno-wrapv -fno-strict-overflow'. But this is > what is dumped into 003t.original with the current trunk. > > { > int a = get_int (); > foo (a + 1 > a); > foo (a + 1 >= a); > foo (0); > foo (a + 1 <= a); > foo (a + 1 < a); > foo (1); > return 0; > } > > Is there a reason that the equality and inequality expressions (and only > those expressions) are simplified? I understand that signed integer > overflow is undefined. I'm more than a little mystified by this question. Unless the target is using something truly weird like saturating arithmetic we can always guarantee that a+1 != a, but we cannot guarantee that a+1 > a. Andrew.