Title
Exporting redeclarations of namespaces
Status
ready
Section
10.2 [module.interface]
Submitter
EWG/CWG

Created on 2025-01-10.00:00:00 last changed 3 weeks ago

Messages

Date: 2025-02-14.17:05:22

Proposed resolution (approved by CWG 2025-02-14):

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 unless it is a namespace. [ Example:
  export module M;
  struct S { int n; };
  typedef S S;
  export typedef S S;     // OK, does not redeclare an entity
  export struct S;        // error: exported declaration follows non-exported declaration
  namespace N {           // external linkage, attached to global module, not exported
    void f();
  }
  namespace N {           // OK, exported namespace redeclaring non-exported namespace
    export void g();
  }
-- end example ]
Date: 2025-02-14.17:05:22

Issue 2921 fixed the following issue with namespaces:

  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();
  }

This is considered a CWG consistency / wording fix. However, the change for that issue also allowed:

  module;
  #include "header"
  export module wrap;

  export using ::feature;               // already allowed previously
  export extern "C++" void feature();   // newly allowed by CWG2921

The CWG chair had neglected to run this new feature past EWG prior to plenary-approving issue 2921 in Wroclaw. Subsequent discussion on the EWG reflector surfaced concerns about missing syntactic differentiation between an intended export-by-redeclaration and an accidental declaration of a different entity because of a slight signature mismatch.

This issues seeks to limit the change to namespaces only; any additional feature in this area should be presented to EWG via a paper.

History
Date User Action Args
2025-02-14 17:05:22adminsetmessages: + msg7963
2025-02-14 16:58:50adminsetstatus: open -> ready
2025-01-10 00:00:00admincreate