https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90905
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> --- > compiling both functions in the samne translatin unit suppresses the warning > for f0. It is quite common for extra code to change inlining decisions. You still get the warning at -O3. > const char *p = "def"; Did you mean to write const char * const p = "def"; (which does warn)? Otherwise, the compiler has no way to know this is a short string, so we end up with a function that returns either the address of a local variable or a pointer to deleted memory (although we don't have a nice PHI like that, even with -std=c++2a to disable extern templates, probably some suboptimal aliasing analysis).