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

2023-01-15


1708. overly-strict requirements for names with C language linkage

Section: 9.11  [dcl.link]     Status: CD4     Submitter: Richard Smith     Date: 2013-06-29

[Moved to DR at the November, 2014 meeting.]

According to 9.11 [dcl.link] paragraph 6,

An entity with C language linkage shall not be declared with the same name as an entity in global scope, unless both declarations denote the same entity; no diagnostic is required if the declarations appear in different translation units.

This restriction is too broad; it does not allow for the so-called stat hack, where a C-linkage function and a class are both declared in global scope, and it does not allow for function overloading, either. It should be revised to apply only to variables.

Additional note (February, 2014):

See also issue 1838 for an interaction with using-declarations.

Proposed resolution (February, 2014):

Change 9.11 [dcl.link] paragraph 6 as follows:

...An entity with C language linkage shall not be declared with the same name as an entity a variable in global scope, unless both declarations denote the same entity; no diagnostic is required if the declarations appear in different translation units...

Additional note, May, 2014:

It was observed that this resolution would allow a definition of main as a C-linkage variable in a namespace. The issue is being returned to "review" status for further discussion.