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 as trees


Richard Henderson <rth@redhat.com> writes:

| On Thu, Dec 13, 2001 at 11:41:37PM +0100, Gabriel Dos Reis wrote:
| > The result of the assignment operation is the value stored in
| > the left operand after the assignment has taken place; the result is
| > an lvalue.
| 
| Taken at face value, this would seem to require that
| 
| 	q = p = 0;
| 
| be implemented as
| 
| 	q = (tmp = 0, p = tmp, tmp);
| 
| where "tmp" is the lvalue.

If implemented that way, how do you explain that

	int x = 0;
	int& f(int y)
	{
	   return x = y;
	}

returns a reference to x -- which if I corerectly undertand Andy
Koenig's explanation motivates the incompatibility introduced in C++?

|  Otherwise, how do you guarantee that
| "p" still contains the value stored?

Good question.  :-)

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com


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