This is the mail archive of the 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

On Fri, 7 Dec 2001, Jason Merrill wrote:
> >>>>> "Alexandre" == Alexandre Oliva <> writes:
> > Would your restriction be extended to constructs such as:
> > int bar, volatile *vpi;
> > int foo = ({ *vpi = bar; });
> > In this case, should *vpi be re-loaded or not?  Does it matter if it's
> > C or C++?
> I would handle this case identically.  It should be reloaded in C++, not in
> C, and should really be written ({ *vpi = bar; bar; }).

As mentioned, I disagree violently.

Would you reload for the expression

	int bar, volatile *vpi;
	({ *vpi = bar; });

which does all the same things, it just doesn't assign to "foo"?

And if you _would_ reload, would you do it for

	int bar, volatile *vpi;
	*vpi = bar;


And if the answer is no, as I think it very clearly is (for both C and
C++), then why would assigning a totally unrelated variable change the
behaviour of accesses through "vpi"?

That does not make sense. C does have some "non-local" behaviour, but
those are very clearly specified by the language. Ie things like the
expression "a || b" has "non-local" behaviour in that depending on the
value of a, b may or may not be read - but this is clearly defined by the
whole meaning of the "||" construct.

I've never heard of "assignment" having non-local behaviour that changes
depending on whether you use the value of the assignment or not.


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