This is the mail archive of the
mailing list for the GCC project.
Re: Volatile MEMs in statement expressions and functions inlined astrees
- From: Jason Merrill <jason at redhat dot com>
- To: Linus Torvalds <torvalds at transmeta dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 07 Dec 2001 18:34:51 +0000
- Subject: Re: Volatile MEMs in statement expressions and functions inlined astrees
- References: <Pine.LNX.email@example.com>
>>>>> "Linus" == Linus Torvalds <firstname.lastname@example.org> 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
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.