Title
Exporting redeclarations of entities not attached to a named module
Status
dr
Section
10.2 [module.interface]
Submitter
Tomasz KamiƄski

Created on 2024-06-20.00:00:00 last changed 4 days ago

Messages

Date: 2024-08-16.19:45:15

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.
Date: 2024-11-15.00:00:00

[Accepted as a DR at the November, 2024 meeting.]

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.

History
Date User Action Args
2024-12-17 09:54:02adminsetstatus: ready -> dr
2024-11-19 12:36:26adminsetstatus: tentatively ready -> ready
2024-08-16 19:45:15adminsetmessages: + msg7799
2024-08-16 19:45:15adminsetstatus: open -> tentatively ready
2024-06-20 00:00:00admincreate