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 inlinedastrees



On 16 Dec 2001, Alexandre Oliva wrote:
> > The way _I_ expect things to work, it should not _matter_ whether a value
> > is used or not. The side effects of that expression take place, and the
> > value is either discarded or not.
>
> So do you say that, in the following chunk of code:
>
> volatile int i;
>
> volatile int& f() { return i; }
>
> i should be dereferenced, even though all we want is a reference to
> it?

Not in f() itself (we explicitly _ask_ for a "volatile int &"), but for
example:

	volatile int i;

	volatile int& f() { return i; }

	main()
	{
		f();
	}

Then I think we are semantically and syntactically on the exact same
ground. Inside main, we _should_ dereference "i", for all the same reasons
that most people would think that we dereference "i" when it stands on its
own.

> If you step back on this one, you're admitting that you can't just say
> `every lvalue always decays to rvalue, be it by using the value last
> assigned to it, be it by accessing it'

That's not what I'm saying at all.

I'm saying

	Every statement-expression decays to a rvalue.

Think about it. That doesn't sound too far-fetched: it _is_ what gcc does
right now for

	volatile int i;

	main()
	{
		i;
	}

agreed?

		Linus


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