P2615 (Meaningful exports) is not fully implemented: Diagnostic required
Nobody has claimed this yet.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Test code ([CE](https://godbolt.org/z/Yov6xcKq7)):
```cpp
export module M;
export template struct S {};
// ❌ - Clang/MSVC/EDG: OK
// ✅ - GCC:
// - error: declaration of partial specialization in unbraced
// export-declaration
// - note: a specialization is always exported alongside its
// primary template
export template struct S {};
// ❌ - Clang/MSVC/EDG: OK
// ✅ - GCC: error: explicit instantiations are not permitted here
export template struct S;
// ❌ - Clang/MSVC/EDG: OK
// ✅ - GCC:
// - error: explicit specializations are not permitted here
// - note: a specialization is always exported alongside its
// primary template
export template <> struct S {};
```
[P2615R1](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2615r1.html) forbids applying `export` directly to partial specializations and explicit instantiations/specializations, as doing so is meaningless. (These declarations are allowed to appear within an `export` block for convenience.) The code above should be diagnosed accordingly.
Related: #147135.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Compiler Explorer test code in the issue and read P2615R1, focusing on the rules for export declarations involving partial specializations, explicit instantiations, and explicit specializations. Compare the current diagnostics with the three examples; done means each directly exported declaration is diagnosed as required, while declarations inside an export block remain permitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100