https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88693
Bug ID: 88693 Summary: Wrong code since r263511 Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: msebor at gcc dot gnu.org Target Milestone: --- Following test-case (isolated from icu package) is miscompiled with -O2: $ cat isolate.c void foo (char *p) { unsigned l = __builtin_strlen (p); unsigned expected = 9; __builtin_printf ("expected: %d, got: %d\n", expected, l); if (l != expected) __builtin_abort (); } int main() { static unsigned char utf8[]={ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1 }; char srcBuffer[100]; __builtin_memcpy(srcBuffer, utf8, sizeof(utf8)); srcBuffer[sizeof(utf8)]=0; foo (srcBuffer); return 0; } $ gcc isolate.c -O2 && ./a.out expected: 9, got: 11 Aborted (core dumped)