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

2025-01-28


2990. Exporting redeclarations of namespaces

Section: 10.2  [module.interface]     Status: open     Submitter: EWG/CWG     Date: 2025-01-10

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.

Possible resolution:

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 ]