On Tue, Oct 17, 2017 at 03:32:25AM -0400, Jeffrey Walton wrote: > On Tue, Oct 17, 2017 at 3:17 AM, David Brown <david@xxxxxxxxxxxxxxx> wrote: > > ... > > If gcc cannot guarantee this, then pretty much every OS and every > > embedded system programmed using gcc works by luck rather than design. > > Sequences like the one in my link are very common, deep down in many > > systems. > > Right, but its not GCC's fault. Using volatile and hoping that things > works as expected has always been held together with duct tape and a > prayer. Also see Ian Lance Taylor's > https://www.airs.com/blog/archives/154. I don't think you've understood what Ian says. > GCC guesses wrong on occasion. It will remove code that has value that > but does not produce an output because the language does not allow us > to express it. Yes, the compiler is bad at guessing what you mean. It does not even try; it only cares about what you *say*. If you believe volatile means something else than it does, the results will not be very satisfying. > The C language lacks what we need to express what we need to do. Its a > failure of the C (and C++) committees. Its not a GCC failure. But "volatile asm" is defined by GCC, not by the C standard. Segher