https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124958
--- Comment #10 from Drea Pinski <pinskia at gcc dot gnu.org> ---
The reason why this inline-asm is broken:
asm volatile("" : "+m,r"(p) : : "memory")
Is because it is not what you think it does.
It does:
asm volatile("" : "+m,r"(p) : "m,0"(p) : "memory");
So it basically does:
pp = &p;
__asm__ __volatile__("" : "=m,r" pp : "m,0" &p : "memory");
So it uses a temp for the assignment. While for the rhs it is not a temp.
When the m constraint is choosen then it will be address of pp passed to the
inline-asm and also the address of a temp to &p. There is no restoring of pp
happening.