Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[module.unit] Is “indirectly exported” a deliberate design? #5527

Open
xmh0511 opened this issue Jun 15, 2022 · 2 comments
Open

[module.unit] Is “indirectly exported” a deliberate design? #5527

xmh0511 opened this issue Jun 15, 2022 · 2 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jun 15, 2022

Consider this example

// translation C 
export module M :C;

// translation U
export module M:U;
import :C;

// translation unit T
export module M;
export import :U;  // #1

[module.unit] says

All module partitions of a module that are module interface units shall be directly or indirectly exported by the primary module interface unit ([module.import]). No diagnostic is required for a violation of these rules.

[module.import] p7 says

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, when a 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-declarations in the module unit purview of U. These rules can in turn lead to the importation of yet more translation units.

It is clear that the U is exported by T since an exported module-import-declaration at #1 imports U in T, which is exactly said in the first emphasized part.

Since T and U are module units of M, the second emphasized part should apply to the module-import-declaration at #1, since the non-exported exported module-import-declaration import :C; appears in U, the module-import-declaration at #1 should also import C. So, C is arguably said that it is indirectly exported by T. All partition module interface units of M are exported by the primary module interface unit of M. There is no violation here.

However, If we compile the example through GCC, it reports an error that:

interface partition is not exported

Not sure whether it is a bug of GCC or [module.unit] falls behind the implementation. Anyway, I think directly or indirectly exported where these adverbs should have their English meanings. U is "directly exported" by T means that U appears in an exported module-import-declaration in T. U is "indirectly exported" by T means that U does not appear in an exported module-import-declaration in T but it is imported by the module-import-declaration.

Wait for the confirmation of the meaning of [module.unit]. If it is a bug in implementations, I will report that bug to the vendors of implementations.

@xmh0511 xmh0511 changed the title [module.unit] Is “indirectly exported” a design [module.unit] Is “indirectly exported” a deliberate design? Jun 15, 2022
@jensmaurer
Copy link
Member

jensmaurer commented Jun 15, 2022

This is the editorial issue tracker, not the Q&A forum for C++. If you believe you have found a bug in an implementation, please report that to the vendor. If the vendor believes their implementation is right, but the standard is wrong, they will report a bug against the standard.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jun 15, 2022

This is the editorial issue tracker, not the Q&A forum for C++. If you believe you have found a bug in an implementation, please report that to the vendor. If the vendor believes their implementation is right, but the standard is wrong, they will report a bug against the standard.

I just want to confirm the intent of [module.unit] and [module.import] p7 have been right read here.

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.

what If there is no such a module-import-declaration that is importing T, it seems to cause confusion here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants