https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94010
--- Comment #3 from Aleksey Covacevice <aleksey.covacevice at gmail dot com> --- (In reply to Richard Biener from comment #1) > It isn't so much about -fmerge-all-constants, this is about not eliding > the automatic variable for the string constant. > > Note it may be the language standard doesn't permit changing the > linkage of 'c', code may end up writing to it, expecting automatic > storage. > Richard, the same optimization is performed by Clang but it requires -fmerge-all-constants (GCC indeed doesn't, in the pointer case). So, perhaps, this optimization should be still related to this flag since the language standard might not allow for such (and the flag breaks compliance anyway)? > So this eliding could be done by the frontend already. Note there's > heuristic > in the gimplifier to eventually emit a copy from a string constant rather > than doing inline initialization but the gimplifier cannot really elide the > variable. > > Also this must have come up in the past.