This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: expression statements, volatiles, and C vs. C++


I'm not sure this follows.  It's stated explicitly that "The
expression is evaluated and its value is discarded."  How can you
evaluate the expression without reading the volatle?

I'm certainly not an expert on this material but I wouldn't think you'd normally read a variable in order to evaluate it as an lvalue. My guess is that evaluating the expression means computing the address for something like "*(p+1)".


Also, there's the non-normative [Note: volatile is a hint to the
implementation to avoid aggressive optimization involving the object
because the value of the object might be changed by means undetectable
by an implementation. See 1.9 for detailed semantics. In general, the
semantics of volatile are intended to be the same in C++ as they are
in C. ]

Yep.


Besides, all that changing this would do is break programs.

Well they're broken anyway since widely-used C++ compilers are choosing to not read the variable under these circumstances. The obvious solution is "don't do that" but there's plenty of code doing this out there, and plenty of developers who need re-educating.


John


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]