https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71813
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu.org --- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #1) > testArray goes out of scope and you access it outside of the scope. > Undefined behavior. GCC 6.1 even warns you about this with -Wall -Wextra -O2: warning: function returns address of local variable [-Wreturn-local-addr] See https://gcc.gnu.org/wiki/FAQ#misoptimization