Date: Fri, 16 Dec 2022 17:58:33 +0000
Hi,
In the SG15 telecon this morning, the issue of whether a named modules can bring in macros via re-exported header units was discussed.
The issue is that the current specification of module-import-declaration: 10.3/7<https://eel.is/c++draft/module.import#7>
When a module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration> imports a translation unit T, it also imports all translation units imported by exported module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration>s in T; such translation units are said to be exported<https://eel.is/c++draft/module.import#def:module,exported> by T.<https://eel.is/c++draft/module.import#7.sentence-1> Additionally, when a module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration> in a module unit of some module M imports another module unit U of M, it also imports all translation units imported by non-exported module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration>s in the module unit purview of U.<https://eel.is/c++draft/module.import#7.sentence-2>91<https://eel.is/c++draft/module.import#footnote-91> These rules can in turn lead to the importation of yet more translation units.<https://eel.is/c++draft/module.import#7.sentence-3>
places no restrictions on "it also imports all translation units imported by exported module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration>s in T;".
It was pointed out that there is a CWG issue
[cpp.import] Example should demonstrate that module imports do not import macros * Issue #199 * cplusplus/CWG * GitHub<https://github.com/cplusplus/CWG/issues/199>
to add an example that importing named modules don't bring in any macros at all. That is a fundamental invariant for anything to work. In addition to adding the example, I believe we need to clarify the wording. The fact that the text is confusing on this aspect is a defect, from my perspective.
Thanks,
-- Gaby
In the SG15 telecon this morning, the issue of whether a named modules can bring in macros via re-exported header units was discussed.
The issue is that the current specification of module-import-declaration: 10.3/7<https://eel.is/c++draft/module.import#7>
When a module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration> imports a translation unit T, it also imports all translation units imported by exported module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration>s in T; such translation units are said to be exported<https://eel.is/c++draft/module.import#def:module,exported> by T.<https://eel.is/c++draft/module.import#7.sentence-1> Additionally, when a module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration> in a module unit of some module M imports another module unit U of M, it also imports all translation units imported by non-exported module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration>s in the module unit purview of U.<https://eel.is/c++draft/module.import#7.sentence-2>91<https://eel.is/c++draft/module.import#footnote-91> These rules can in turn lead to the importation of yet more translation units.<https://eel.is/c++draft/module.import#7.sentence-3>
places no restrictions on "it also imports all translation units imported by exported module-import-declaration<https://eel.is/c++draft/module.import#nt:module-import-declaration>s in T;".
It was pointed out that there is a CWG issue
[cpp.import] Example should demonstrate that module imports do not import macros * Issue #199 * cplusplus/CWG * GitHub<https://github.com/cplusplus/CWG/issues/199>
to add an example that importing named modules don't bring in any macros at all. That is a fundamental invariant for anything to work. In addition to adding the example, I believe we need to clarify the wording. The fact that the text is confusing on this aspect is a defect, from my perspective.
Thanks,
-- Gaby
Received on 2022-12-16 17:58:36