Global-scope :: in nested-name-specifier
Clause [11] [class]
Clark Nelson

Created on 2002-05-16.00:00:00 last changed 96 months ago


Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting as paper N3259.]

Date: 2011-02-15.00:00:00

Proposed resolution (February, 2011):

The proposed resolution will be submitted as a separate document.

Date: 2004-09-10.00:00:00

In looking at a large handful of core issues related to elaborated-type-specifiers and the naming of classes in general, I discovered an odd fact. It turns out that there is exactly one place in the grammar where nested-name-specifier is not immediately preceded by "::opt": in class-head, which is used only for class definitions. So technically, this example is ill-formed, and should evoke a syntax error:

  struct A;
  struct ::A { };

However, all of EDG, GCC and Microsoft's compiler accept it without a qualm. In fact, I couldn't get any of them to even warn about it.

Suggested resolution:

It would simplify the grammar, and apparently better reflect existing practice, to factor the global-scope operator into the rule for nested-name-specifier.

Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3352
2011-04-10 00:00:00adminsetstatus: tentatively ready -> fdis
2011-02-28 00:00:00adminsetstatus: drafting -> tentatively ready
2010-08-23 00:00:00adminsetstatus: review -> drafting
2008-02-03 00:00:00adminsetmessages: + msg1580
2008-02-03 00:00:00adminsetstatus: open -> review
2002-05-16 00:00:00admincreate