Title
Syntactic disambiguation and trailing-return-types
Status
drafting
Section
8.9 [stmt.ambig]
Submitter
Michael Wong

Created on 2010-11-08.00:00:00 last changed 9 months ago

Messages

Date: 2023-06-13.16:05:19

CWG 2023-06-13

Addressed by paper P2915R0.

Date: 2023-05-13.11:43:16

CWG 2023-05-12

Both 8.9 [stmt.ambig] and 9.3.3 [dcl.ambig.res] need to be adjusted.

Date: 2011-03-15.00:00:00

Notes from the March, 2011 meeting:

CWG agreed that the presence of auto should be considered in disambiguation, even though it is formally handled semantically rather than syntactically.

Date: 2010-11-08.00:00:00

Because the restriction that a trailing-return-type can appear only in a declaration with “the single type-specifier auto” (9.3.4.6 [dcl.fct] paragraph 2) is a semantic, not a syntactic, restriction, it does not influence disambiguation, which is “purely syntactic” (8.9 [stmt.ambig] paragraph 3). Consequently, some previously unambiguous expressions are now ambiguous. For example:

struct A {
  A(int *);
  A *operator()(void);
  int B;
};

int *p;
typedef struct BB { int C[2]; } *B, C;

void foo() {
// The following line becomes invalid under C++0x:
  A (p)()->B;  // ill-formed function declaration

// In the following,
// - B()->C is either type-id or class member access expression
// - B()->C[1] is either type-id or subscripting expression
// N3126 subclause 8.2 [dcl.ambig.res] does not mention an ambiguity
// with these forms of expression
  A a(B ()->C);  // function declaration or object declaration
  sizeof(B ()->C[1]);  // sizeof(type-id) or sizeof on an expression
}
History
Date User Action Args
2023-06-13 16:05:19adminsetmessages: + msg7313
2023-05-13 11:43:16adminsetmessages: + msg7285
2011-04-10 00:00:00adminsetmessages: + msg3274
2011-04-10 00:00:00adminsetstatus: open -> drafting
2010-11-08 00:00:00admincreate