https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83860
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- N.B. compiling with -fstack-reuse=none will prevent the optimizer from reusing the stack space immediately, so the dangling references can still be used to access the temporaries after their lifetime ends.