https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83501
Bug ID: 83501 Summary: [8 Regression] strlen(a) not folded after strcpy(a, "...") Product: gcc Version: 8.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: --- GCC 7 and prior folded into a constant the strlen call in the following simple test case but GCC 8 no longer does. $ cat z.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout z.c extern char* stpcpy (char*, const char*); extern char* strcpy (char*, const char*); char a[4]; void f (void) { strcpy (a, "abc"); if (__builtin_strlen (a) != 3) __builtin_abort (); } ;; Function f (f, funcdef_no=0, decl_uid=1899, cgraph_uid=0, symbol_order=1) f () { long unsigned int _1; <bb 2> [local count: 1073741825]: MEM[(char * {ref-all})&a] = MEM[(char * {ref-all})"abc"]; _1 = __builtin_strlen (&a); if (_1 != 3) goto <bb 3>; [0.00%] else goto <bb 4>; [99.96%] <bb 3> [count: 0]: __builtin_abort (); <bb 4> [local count: 1073312327]: return; }