> On Dec 3, 2015, at 12:29 AM, Bernd Edlinger <bernd.edlin...@hotmail.de> wrote: > >> ... >> If the goal is to order things wrt x, why wouldn't you just reference x? >> >> x = 1; >> asm volatile("nop":"+m"(x)); >> x = 0; >> > > Exactly, that is what I mean. Either the asm can use memory clobber > or it can use output and/or input clobbers or any combination of that. > > The problem with basic asm is not that it is basic, but that it does not > have any outputs nor any inputs and it has no way to specify what it > might clobber. > > Therefore I think the condition for the warning should not be that the > asm is "basic", but that has zero outputs, zero inputs and zero clobbers. > That would make more sense to me.
I don't think so. Basic asm has a somewhat documented specification, in particular it is defined to be volatile. Some revs of GCC got this wrong, but such cases are obviously bugs. It does omit any statement about clobbers, true. And the difficulty is that people have made assumptions, not necessarily supported by documentation. And those assumptions may have been invalid on some platforms in some revs by new optimizations. The prevalence of confusion about basic asm is the reason why warning about it is potentially useful. On the other hand, asm volatile ("foo":::) has a different meaning. That specifically says that "foo" doesn't clobber anything (and, implicitly, that it does not rely on any program variable being up to date in memory). While that isn't all that common, it is certainly possible. For example, if I want to turn on an LED on the device front panel, I might use such a statement (on machines where the instruction set allows me to do this without using registers). Since I explicitly stated "this doesn't clobber anything" I would not expect or want a warning. paul