Title
Is rvalue.field an rvalue?
Status
cd1
Section
7.6.1.5 [expr.ref]
Submitter
Gabriel Dos Reis

Created on 2003-06-15.00:00:00 last changed 189 months ago

Messages

Date: 2004-03-15.00:00:00

[Voted into WP at March 2004 meeting.]

Date: 2003-10-15.00:00:00

Proposed Resolution (October 2003):

Change the second bullet of 7.6.1.5 [expr.ref] paragraph 4 to read:

If E1 is an lvalue, then E1.E2 is an lvalue; otherwise, it is an rvalue.
Date: 2003-10-15.00:00:00

Notes from October 2003 meeting:

We agree the reference should be an rvalue, and a change along the lines of that recommended by Mike Miller is reasonable.

Date: 2022-02-18.07:47:23

Consider

  typedef
    struct {
      int a;
    } A;

  A f(void)
  {
    A a;
    return a;
  }

  int main(void)
  {
    int* p = &f().a;   // #1
  }

Should #1 be rejected? The standard is currently silent.

Mike Miller: I don't believe the Standard is silent on this. I will agree that the wording of 7.6.1.5 [expr.ref] bullet 4.2 is unfortunate, as it is subject to misinterpretation. It reads,

If E1 is an lvalue, then E1.E2 is an lvalue.
The intent is, "and not otherwise."

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2004-04-09 00:00:00adminsetmessages: + msg1006
2004-04-09 00:00:00adminsetstatus: ready -> wp
2003-11-15 00:00:00adminsetmessages: + msg911
2003-11-15 00:00:00adminsetmessages: + msg910
2003-11-15 00:00:00adminsetstatus: open -> ready
2003-06-15 00:00:00admincreate