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

2024-11-11


2921. Exporting redeclarations of entities not attached to a named module

Section: 10.2  [module.interface]     Status: tentatively ready     Submitter: Tomasz Kamiński     Date: 2024-06-20

Consider:

  export module mod;
  extern "C++" void func();
  export extern "C++" {
    void func();
  }

Per 10.2 [module.interface] paragraph 6, this is currently ill-formed, but implementation treatment varies and there seems to be little rationale why this should be ill-formed for entities not attached to a named module.

The rule also makes the following example ill-formed, which was intended to be well-formed:

  export module M;
  namespace N { // external linkage, attached to global module, not exported
    void f();
  }
  namespace N { // error: exported namespace, redeclares non-exported namespace
    export void g();
  }

The mental model here is that for an entity not attached to a named module, exportedness is not a meaningful property of that entity.

Proposed resolution (approved by CWG 2024-08-16):

Change in 10.2 [module.interface] paragraph 6 as follows:

A redeclaration of an entity X is implicitly exported if X was introduced by an exported declaration; otherwise it shall not be exported if it is attached to a named module.