The following code miscompiles with all GCCs except mainline. ------------------------------------------------------ long fff[10]; extern "C" void abort (void); long f(long a, long b) { int i; a = *((long*)(a+5))>?*((long*)(a+1)); for(i=0;i<10;i++) fff[i] = a; } int main(void) { int i; long a[2] = {10,5}; f((long)(&a)-1,0); for(i = 0;i<10;i++) if (fff[i]!=10) abort (); } ------------------------------------------------------ The fix is the same as Roger Sayle's fix for PR18548.
-- Summary: Wrong code for MIN_EXPR and MAX_EXPR Product: gcc Version: 4.0.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P2 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: steven at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org,roger at eyesopen dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19068