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

2010-03-06 Thread Andrew Haley
On 06/03/10 15:54, John Regehr wrote: >> 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 y

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

2010-03-06 Thread John Regehr
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 evalua

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

2010-03-06 Thread Andrew Haley
On 03/06/2010 04:43 AM, John Regehr wrote: > The question is, what should C and C++ compilers do with this code? > > volatile int x; > > void foo (void) { > x; > } > > This question is not totally stupid: embedded systems use code like this > when reading a hardware register has a usef

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

2010-03-05 Thread John Regehr
The question is, what should C and C++ compilers do with this code? volatile int x; void foo (void) { x; } This question is not totally stupid: embedded systems use code like this when reading a hardware register has a useful side effect (usually clearing the register). It is reas