https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103827
Jan Hubicka <hubicka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org, | |jason at redhat dot com, | |jwakely at redhat dot com --- Comment #1 from Jan Hubicka <hubicka at gcc dot gnu.org> --- Is this really invalid implementation of foo? #include <string> int foo (const std::string s) { std::string *ptr = const_cast<std::string *> (&s); *ptr = "I am long string over 15 chars"; return s.size(); } similarly I am not 100% sure about non-escaping. Perhaps the destructor of the type passed may check that pointer is somewhere in global memory?