https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83311
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic, | |missed-optimization CC| |msebor at gcc dot gnu.org --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Rather than focusing on optimizing such code it would be more useful to diagnose it. The alloca case should be diagnosed with -Wreturn-local-addr as suggested in bug 81811. The malloc/calloc (and perhaps even attribute alloc_size) with some new warning designed to detect memory leaks. Without a warning, the optimization will mask hard to reproduce bugs, some of which will only be reproducible with optimization disabled, or with other compilers, or with valgrind or similar tools.