https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94010
Bug ID: 94010 Summary: [missed optimization] -fmerge-all-constants misses simple array merging Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: aleksey.covacevice at gmail dot com Target Milestone: --- -fmerge-all-constants misses a very simple optimization scenario involving an array: extern void g(const char* c); void f() { const char c[] = "12345"; g(c); } produces a local array (with or without the flag). If `const char c[]` is replaced by `const char* c`, the above code produces a global array as expected. This seems to be the case in every GCC version I have tested, starting from 4.9.