This actually happens in libicu, preventing genbrk (and hence openoffice and texlive) to work.
# gcc -O1 icubug.c && ./a.out Aborted With -O0 it works. The wrong transformation is done by dom1, it transforms the loop into a linear sequence without backedges. <bb 2>: goto <bb 8>; <bb 3>: # start_16 = PHI <mid_25(5), start_21(8)> # limit_19 = PHI <limit_22(5), mid_25(8)> # lastMid_15 = PHI <mid_25(5), mid_25(8)> <bb 4>: # start_1 = PHI <start_16(3)> # limit_2 = PHI <limit_19(3)> # lastMid_3 = PHI <mid_25(3)> D.2744_9 = start_1 + limit_2; mid_10 = D.2744_9 / 2; goto <bb 7>; <bb 5>: if (result_14 > 0) goto <bb 3>; else goto <bb 6>; <bb 6>: D.2754_17 = cnvNameType[mid_25].type; D.2753_18 = converterData[D.2754_17]; <bb 7>: # D.2753_4 = PHI <D.2753_18(6), 0B(4)> return D.2753_4; <bb 8>: # start_21 = PHI <0(2)> # limit_22 = PHI <3(2)> # lastMid_23 = PHI <4294967295(2)> D.2744_24 = start_21 + limit_22; mid_25 = D.2744_24 / 2; D.2746_12 = cnvNameType[mid_25].name; result_14 = __builtin_strcmp (realName_13(D), D.2746_12); if (result_14 < 0) goto <bb 3>; else goto <bb 5>; -- Summary: dom1 miscompiles binary search Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: critical Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: matz at gcc dot gnu dot org GCC host triplet: x86_64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43402