This is the mail archive of the gcc-patches@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: Volatile MEMs in statement expressions and functions inlined astrees


>>>>> "Linus" == Linus Torvalds <torvalds@transmeta.com> writes:

> On Fri, 7 Dec 2001, Jason Merrill wrote:
>> 
>> I would agree with that interpretation, were it not for the lvalue bit.
>> Indeed, my point is that that's the difference between C and C++.

> Actually, I can _guarantee_ that my reading of the standard is correct.

> Proof: if your reading of the standard is correct, then the statement

> 	volatile int p;

> 	p = 0;

> should always generate a store _and_ a load.

I don't think that follows.

> Why? According to the C standard the expression "p = 0" will return a
> value whether that return value is _used_ or not. There is no provision
> for "..only if used".

Yes, it returns a value.  In C++, that value is an lvalue.  Since the value
is not used, no lvalue-to-rvalue conversion is performed, so no load is
generated.

Again, my assertion is that in C++,

  q = p = 0

is equivalent to

  q = (p = 0, p)

Do you think that the latter should not load from p?

Did you get a chance to look at the URL I cited?

> Obviously, bug or not, depending on the exact behaviour of "volatile" in C
> (or C++) is asking for trouble, it's just too badly defined.

Agreed.

Jason


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