https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80728

--- Comment #2 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Nowadays C has atomics and fences in the language standard, so it doesn't
matter if x() had

  asm volatile("":::"memory");

or

  __atomic_{signal,thread}_fence(__ATOMIC_ACQ_REL);

or

  return __atomic_load_n(&b, __ATOMIC_SEQ_CST);

In all three cases the compiler needs to place a memory barrier internally, and
in the latter two it's impossible to argue that the source code is missing a
clobber.

I think it's correct that "memory" clobber cannot touch non-addressable auto
vars, but extending that to static variables seems wrong. I'm not aware of any
instance (apart from this bug) where gcc does that.

Reply via email to