Compiling this test program with gcc-4.4-20090623 fails with a linker error:
> cat pr39867-redux.c int main (void) { int exp = -1; /* Wrong folding of the LHS to an unsigned MIN leads to 2 != 4294967295. */ if ((exp < 2 ? (unsigned int) exp : 2U) != -1U) link_error (); return 0; } > gcc -O2 pr39867-redux.c /tmp/ccwtpmSD.o: In function `main': pr39867-redux.c:(.text+0x7): undefined reference to `link_error' collect2: ld returned 1 exit status This is a regression from gcc-4.3.3 and earlier releases. The test case is a variant of PR39867, which got fixed. That bug report was about fold-const.c turning a ?: into MAX and wrongly changing a signed compare to an unsigned compare in the process. There are additional cases that turn ?: into MIN, but they weren't considered or fixed. I'll attach the test case and a proposed fix. -- Summary: comparison in lhs of ?: incorrectly converted to unsigned min Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mikpe at it dot uu dot se GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40547