https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86532
Bug ID: 86532 Summary: [9 Regression] Wrong code due to a wrong strlen folding starting with r262522 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 simple test-case is miscompiled: $ cat part.c static const char dwarf_scnnames[2][3] = { [0] = "1", [1] = "12", }; int main (int argc, char **argv) { int cnt, x; for (cnt = 0; cnt < 2; cnt++) x += __builtin_strlen (dwarf_scnnames[cnt]); __builtin_printf ("value: %d\n", x); if (x != 3) __builtin_abort (); return 0; } $ gcc /tmp/part.c -O0 && ./a.out value: 2 Aborted (core dumped)