https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67316
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This is undefined behavior. Returning the address of a local variable is undefined. If you want to trick the compiler though here is a better solution (than just moving the address taking out of the return): ptr_t GC_approx_sp2(void) { volatile word dummy; dummy = 42; ptr_t ret = (ptr_t)&dummy; asm("":"+r"(ret)); return ret; }