https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119312
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org, | |jakub at gcc dot gnu.org, | |jamborm at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, you're basically asking for interprocedural optimization which if it proves that certain TREE_STATIC non-const VAR_DECL which is not visible to code outside of what is being compiled together (for non-LTO not visible outside of the current TU, for LTO outside of everything LTO sees) is never written to and can't ever escape to other TUs can be turned into const even when it wasn't declared that way. Wonder how often would that trigger, e.g. in your testcase we'd need to know that strcmp doesn't escape the address (maybe we know that already, haven't checked).