Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


527. Problems with linkage of types

Section:6.7  [basic.link]    Status:CD2    Submitter:Daveed Vandevoorde    Date:28 July 2005

[Voted into WP at October, 2009 meeting.]

The resolution ofissue 389 makes codelike

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

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

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

Notes from the October, 2005 meeting:

The Evolution Working Group is discussing changes that wouldaddress this issue. CWG will defer consideration until the outcomeof the EWG discussions is clear.

Notes from the April, 2006 meeting:

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

Additional note (April, 2006):

Even the restriction of the rule to functions and objects withexternal linkage may not be exactly what we want. Consider an examplelike:

    namespace {        struct { int i; } s;    }

The variables has external linkage but can't be namedoutside its translation unit, so there's again no reason to prohibituse of a type without linkage in its declaration.

Notes from the June, 2008 meeting:

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

Proposed resolution (June, 2009):

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

...A type without linkage shall not be used as the type of avariable or function withexternal linkage, unless

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




[8]ページ先頭

©2009-2026 Movatter.jp