https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114597
Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xry111 at gcc dot gnu.org --- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- (In reply to wierton from comment #3) > Thanks a lot, I have checked it out. > > I'm still somewhat confused. Does the difference in compilation stem from > GCC interpreting "=m" and "=r" differently, leading it to assume that once > "n.p" is declared as an output operand without matched input declaration > (eg. "=m" expects "m", "=r" expects "r"), its value is expected to change? > > ``` > asm("":"=m"(n.p):"r"(n.p)); // n.p is expected to change > asm("":"=r"(n.p):"r"(n.p)); // n.p can retain its value > asm("":"=m"(n.p):"m"(n.p)); // n.p can retain its value > ``` I believe the second form is still incorrect and it just works by luck. To ensure it work you have to do: asm("mov %1,%0":"=r"(n.p):"r"(n.p)); Or asm("":"+r"(n.p)); Not so sure about the third form.