cplusplus / cplusplus/draft

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

Open
#5,527 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the quoted [module.unit] and [module.import] paragraphs and reproduce the example with GCC. Determine whether the wording permits C to be indirectly exported through U, then document the confirmed interpretation or the needed standard-text change.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.