[module.private.frag] A confused example
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
export module A;
// #1
export inline void fn_e(); // error: exported inline function fn_e not defined
// before private module fragment
// #2
inline void fn_m(); // OK, module-linkage inline function
static void fn_s();
export struct X;
export void g(X *x) {
fn_s(); // OK, call to static function in same translation unit
fn_m(); // OK, call to module-linkage inline function
}
export X *factory(); // OK
module :private;
struct X {}; // definition not reachable from importers of A
X *factory() {
return new X ();
}
void fn_e() {}
void fn_m() {}
void fn_s() {}
In this example, #1 and #2 both attach to module A, they have external or module linkage, respectively. In terms of this case, [basic.def.odr] p11, [dcl.inline] p5 and p7 should apply to both #1 and #2. The definition of definition domain is defined as that
A definition domain is a private-module-fragment or the portion of a translation unit excluding its private-module-fragment (if any).
I'm not sure whether the intent of this rule is that a private-module-fragment can divide out another definition domain in a translation unit. If it is, #2 should be ill-formed since it is odr-used in the first definition domain but its definition appears in another domain, as per [basic.def.odr] p11
A definition of an inline function or variable shall be reachable from the end of every definition domain in which it is odr-used outside of a discarded statement.
Except that, I'm not seeing any difference between #1 and #2 in terms of this example, that is, they should have the same treatment unless there are some normative rules that differentiate them in this case.
Contributor guide
No contributing guide indexed for this repository
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 supplied module A example and read [basic.def.odr] p11 and [dcl.inline] p5/p7 alongside the definition-domain and private-module-fragment rules. Done means determining whether the two inline functions have different requirements and recording the normative clarification in the draft.
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
- 35/100