Title
Problems with linkage of types
Status
cd2
Section
6.6 [basic.link]
Submitter
Daveed Vandevoorde

Created on 2005-07-28.00:00:00 last changed 144 months ago

Messages

Date: 2009-10-15.00:00:00

[Voted into WP at October, 2009 meeting.]

Date: 2009-06-15.00:00:00

Proposed resolution (June, 2009):

Change 6.6 [basic.link] paragraph 8 as follows:

...A type without linkage shall not be used as the type of a variable or function with external linkage, unless

  • the variable or function has extern "C" C language linkage (9.11 [dcl.link]), or

  • the variable or function is declared within an unnamed namespace (9.8.2 [namespace.def]), or

  • the variable or function is not used (6.3 [basic.def.odr]) or is defined in the same translation unit.

[Drafting note: the context shown for the preceding resolution assumes that the resolution for issue 757 has been applied.]

Date: 2008-06-15.00:00:00

Notes from the June, 2008 meeting:

Paper N2657, adopted at the June, 2008 meeting, allows local and unnamed types to be used as template parameters. That resolution is narrowly focused, however, and does not address this issue.

Date: 2006-04-15.00:00:00

Additional note (April, 2006):

Even the restriction of the rule to functions and objects with external linkage may not be exactly what we want. Consider an example like:

    namespace {
        struct { int i; } s;
    }

The variable s has external linkage but can't be named outside its translation unit, so there's again no reason to prohibit use of a type without linkage in its declaration.

Date: 2006-04-15.00:00:00

Notes from the April, 2006 meeting:

The CWG agreed that the restriction in 6.6 [basic.link] paragraph 8 on use of a type without linkage should apply only to variables and functions with external linkage, not to variables and functions with internal linkage (i.e., the example should be accepted). This is a separate issue from the question before the EWG and should be resolved independently.

Date: 2005-10-15.00:00:00

Notes from the October, 2005 meeting:

The Evolution Working Group is discussing changes that would address this issue. CWG will defer consideration until the outcome of the EWG discussions is clear.

Date: 2005-07-28.00:00:00

The resolution of issue 389 makes code like

    static struct {
        int i;
        int j;
    } X;

ill-formed. This breaks a lot of code for no apparent reason, since the name X is not known outside the translation unit in which it appears; there is therefore no danger of collision and no need to mangle its name.

There has also been recent discussion on the email reflectors as to whether the restrictions preventing use of types without linkage as template arguments is needed or not, with the suggestion that a mechanism like that used to give members of the unnamed namespace unique names could be used for unnamed and local types. See also issue 488, which would become moot if types without linkage could be used as template parameters.

History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: dr -> cd2
2009-11-08 00:00:00adminsetmessages: + msg2424
2009-11-08 00:00:00adminsetstatus: ready -> dr
2009-08-03 00:00:00adminsetstatus: review -> ready
2009-06-19 00:00:00adminsetmessages: + msg2037
2009-06-19 00:00:00adminsetstatus: drafting -> review
2008-06-29 00:00:00adminsetmessages: + msg1707
2006-04-22 00:00:00adminsetmessages: + msg1329
2006-04-22 00:00:00adminsetmessages: + msg1328
2006-04-22 00:00:00adminsetstatus: open -> drafting
2005-10-22 00:00:00adminsetmessages: + msg1261
2005-07-28 00:00:00admincreate