https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92157
Bug ID: 92157 Summary: incorrect strcmp() == 0 result for unknown strings Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The strcmp optimization checked in r276773 doesn't handle the following case correctly, causing regressions in the arj package. $ cat a.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout a.c char a[3]; __attribute__ ((noipa)) int f (const char *s) { int n = __builtin_strlen (s); if (__builtin_strcmp (s, a) == 0) __builtin_abort (); return n; } int main (void) { a[0] = '1'; f (""); } ;; Function f (f, funcdef_no=0, decl_uid=1931, cgraph_uid=1, symbol_order=1) __attribute__((noipa, noinline, noclone, no_icf)) f (const char * s) { <bb 2> [count: 0]: __builtin_abort (); } ;; Function main (main, funcdef_no=1, decl_uid=1935, cgraph_uid=2, symbol_order=2) (executed once) main () { <bb 2> [local count: 1073741824]: a[0] = 49; f (""); return 0; }