P1979R0: Resolution to US086
Author: Mathias Stearn
Date: 2019-11-08
Effect of this change
This change is intended to prevent import
declarations in the global module fragment of a module unit from being implicitly imported when other units of the same module import that unit. Other NB comment resolutions will ensure that such import
declarations must come from #include
expansion (possibly by translation to an import
) and must not be explictlity export
ed.
This is believed to be an unintentional change in behavior from the Modules TS caused by a change in specification mechanisms.
Example
import <vector>;
module;
#include "uses_vector.h"
module A:partition;
module A;
import :partition;
std::vector<int> x;
This change makes the last line ill-formed because it refers to std::vector
which is not visible. Previously the import
of <vector>
was implicitly imported into the interface.cpp
translation unit.
Wording
Modify 10.3 [module.import] paragraph 6 as follows:
When a module-import-declaration imports a translation unit T, it also imports all translation units imported by exported module-import-declarations in T; such translation units are said to be exported by T. Additionally, wWhen a module-import-declaration in a module unit of some module M
imports another module unit U of the same module M
, it also imports all translation units imported by non-exportedall module-import-declarations in the module unit purview of Uthat module unit. [ Footnote: This is consistent with the rules for visibility of imported names ([basic.scope.namespace]). — end footnote ] These rules may in turn lead to the importation of yet more translation units.
P1979R0: Resolution to US086
Author: Mathias Stearn
Date: 2019-11-08
Effect of this change
This change is intended to prevent
import
declarations in the global module fragment of a module unit from being implicitly imported when other units of the same module import that unit. Other NB comment resolutions will ensure that suchimport
declarations must come from#include
expansion (possibly by translation to animport
) and must not be explictlityexport
ed.This is believed to be an unintentional change in behavior from the Modules TS caused by a change in specification mechanisms.
Example
This change makes the last line ill-formed because it refers to
std::vector
which is not visible. Previously theimport
of<vector>
was implicitly imported into theinterface.cpp
translation unit.Wording
Modify 10.3 [module.import] paragraph 6 as follows: