Title
Syntactic ambiguity of the attribute notation
Status
cd2
Section
9.12.1 [dcl.attr.grammar]
Submitter
Daveed Vandevoorde

Created on 2009-09-23.00:00:00 last changed 179 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting as document N3063.]

Date: 2009-11-15.00:00:00

Proposed resolution (November, 2009):

Add the following paragraph at the end of 9.3.3 [dcl.ambig.res]:

Two consecutive left square bracket tokens shall appear only when introducing an attribute-specifier. [Note: If two consecutive left square brackets appear where an attribute-specifier is not allowed, the program is ill-formed even if the brackets match an alternative grammar production. —end note] [Example:

  int p[10];
  void f() {
    int x = 42;
    int(p[[x]{return x;}()]);  // Error: malformed attribute on a nested
                               // declarator-id and not a function-style cast of
                               // an element of p.
    new int[[]{return x;}()];  // Error even though attributes are not allowed
  }                            // in this context.

end example]

Date: 2009-11-08.00:00:00

The [[ ... ]] notation for attributes was thought to be completely unambiguous. However, it turns out that two [ characters can be adjacent and not be an attribute-introducer: the first could be the beginning of an array bound or subscript operator and the second could be the beginning of a lambda-introducer. This needs to be explored and addressed.

(See also issue 951.)

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2698
2010-03-29 00:00:00adminsetstatus: review -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2540
2010-02-16 00:00:00adminsetstatus: drafting -> review
2009-11-08 00:00:00adminsetstatus: open -> drafting
2009-09-23 00:00:00admincreate