CWG Issue 564 (original) (raw)

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

2025-11-05


564. Agreement of language linkage or _linkage-specification_s?

Section: 9.12 [dcl.link]Status: CD2Submitter: Daveed VandevoordeDate: 8 March 2006

[Voted into the WP at the March, 2009 meeting.]

The wording of 9.12 [dcl.link] paragraph 5 is suspect:

If two declarations of the same function or object specify different_linkage-specification_s (that is, the _linkage-specification_s of these declarations specify different _string-literal_s), the program is ill-formed if the declarations appear in the same translation unit, and the one definition rule (3.2) applies if the declarations appear in different translation units.

But what if only one of the declarations has a_linkage-specification_, while the other is left with the default C++ linkage? Shouldn't this restriction be phrased in terms of the functions’ or objects’ language linkage rather than_linkage-specification_s?

(Additional note [wmm]: Is the ODR the proper vehicle for enforcing this requirement? This is dealing with declarations, not necessarily definitions. Shouldn't this say “ill-formed, no diagnostic required” instead of some vague reference to the ODR?)

Proposed resolution (June, 2008):

Change 9.12 [dcl.link] paragraph 5 as follows:

If two declarations of the same function or object declare functions with the same name and parameter-type-list (9.3.4.6 [dcl.fct]) to be members of the same namespace or declare objects with the same name to be members of the same namespace specify different _linkage-specification_s (that is, the_linkage-specification_s of these declarations specify different_string-literal_s) and the declarations give the names different language linkages, the program is ill-formed if the declarations appear in the same translation unit, and the one definition rule (6.3 [basic.def.odr]) applies; no diagnostic is required if the declarations appear in different translation units.