Name lookup in elaborated-type-specifiers
6.5.6 [basic.lookup.elab]
Jack Rouse

Created on 2000-09-14.00:00:00 last changed 162 months ago


Date: 2003-04-15.00:00:00

[Voted into WP at April 2003 meeting.]

Date: 2002-10-15.00:00:00

Proposed resolution (October 2002):

As given in N1376=02-0034. Note that the inserts and strikeouts in that document do not display correctly in all browsers; <del> --> <strike> and <ins> --> <b>, and the similar changes for the closing delimiters, seem to do the trick.

Date: 2002-04-15.00:00:00

Notes from the 4/02 meeting:

This will be consolidated with the changes for issue 254. See also issue 298.

Date: 2004-09-10.00:00:00

I have some concerns with the description of name lookup for elaborated type specifiers in 6.5.6 [basic.lookup.elab]:

  1. Paragraph 2 has some parodoxical statements concerning looking up names that are simple identifers:

    If the elaborated-type-specifier refers to an enum-name and this lookup does not find a previously declared enum-name, the elaborated-type-specifier is ill-formed. If the elaborated-type-specifier refers to an [sic] class-name and this lookup does not find a previously declared class-name... the elaborated-type-specifier is a declaration that introduces the class-name as described in 6.4.2 [basic.scope.pdecl]."

    It is not clear how an elaborated-type-specifier can refer to an enum-name or class-name given that the lookup does not find such a name and that class-name and enum-name are not part of the syntax of an elaborated-type-specifier.

  2. The second sentence quoted above seems to suggest that the name found will not be used if it is not a class name. typedef-name names are ill-formed due to the sentence preceding the quote. If lookup finds, for instance, an enum-name then a new declaration will be created. This differs from C, and from the enum case, and can have surprising effects:

        struct S {
           enum E {
               one = 1
           class E* p;     // declares a global class E?

    Was this really the intent? If this is the case then some more work is needed on 6.5.6 [basic.lookup.elab]. Note that the section does not make finding a type template formal ill-formed, as is done in [dcl.type.elab]. I don't see anything that makes a type template formal name a class-name. So the example in [dcl.type.elab] of friend class T; where T is a template type formal would no longer be ill-formed with this interpretation because it would declare a new class T.

(See also issue 254.)

Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetmessages: + msg857
2003-04-25 00:00:00adminsetstatus: ready -> wp
2002-11-08 00:00:00adminsetstatus: review -> ready
2002-05-10 00:00:00adminsetmessages: + msg619
2002-05-10 00:00:00adminsetstatus: drafting -> review
2000-11-18 00:00:00adminsetmessages: + msg416
2000-11-18 00:00:00adminsetstatus: open -> drafting
2000-09-14 00:00:00admincreate