Title
Linkage of nameless class-scope enumeration types
Status
cd1
Section
6.6 [basic.link]
Submitter
Daveed Vandevoorde

Created on 2000-03-13.00:00:00 last changed 26 months ago

Messages

Date: 2001-10-15.00:00:00

[Moved to DR at 10/01 meeting.]

Date: 2022-02-18.07:47:23

Proposed resolution:

Change text in 6.6 [basic.link] paragraph 5 from:

In addition, a member function, static data member, class or enumeration of class scope has external linkage if the name of the class has external linkage.
to:
In addition, a member function, a static data member, a named class or enumeration of class scope, or an unnamed class or enumeration defined in a class-scope typedef declaration such that the class or enumeration has the typedef name for linkage purposes (9.2.4 [dcl.typedef]), has external linkage if the name of the class has external linkage.
Date: 2022-02-18.07:47:23
6.6 [basic.link] paragraph 4 says (among other things):
A name having namespace scope has external linkage if it is the name of
  • [...]
  • a named enumeration (9.7.1 [dcl.enum]), or an unnamed enumeration defined in a typedef declaration in which the enumeration has the typedef name for linkage purposes (9.2.4 [dcl.typedef])
That prohibits for example:
    typedef enum { e1 } *PE;
    void f(PE) {}  // Cannot declare a function (with linkage) using a
		   // type with no linkage.

However, the same prohibition was not made for class scope types. Indeed, 6.6 [basic.link] paragraph 5 says:

In addition, a member function, static data member, class or enumeration of class scope has external linkage if the name of the class has external linkage.

That allows for:

    struct S {
       typedef enum { e1 } *MPE;
       void mf(MPE) {}
    };

My guess is that this is an unintentional consequence of 6.6 [basic.link] paragraph 5, but I would like confirmation on that.

History
Date User Action Args
2022-02-18 07:47:23adminsetmessages: + msg6653
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetstatus: dr -> wp
2002-05-10 00:00:00adminsetmessages: + msg662
2001-11-09 00:00:00adminsetstatus: ready -> dr
2001-05-20 00:00:00adminsetstatus: review -> ready
2000-09-16 00:00:00adminsetstatus: drafting -> review
2000-03-13 00:00:00admincreate