[basic.link] p19 Two confusing comments in the formal 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;
static void f() {}
// ...
struct S { void (&ref)(); } s{f}; // OK, value is TU-local
constexpr extern struct W { S &s; } wrap{s}; // OK, value is not TU-local
//...
static auto x = []{f();}; // OK
auto x2 = x; // error: the closure type is TU-local
int y = ([]{f();}(),0); // error: the closure type is not TU-local
Per [basic.link#16.2]
A value or object is TU-local if either
- it is, or is a pointer to, a TU-local function or the object associated with a TU-local variable, or
- it is an object of class or array type and any of its subobjects or any of the objects or functions to which its non-static data members of reference type refer is TU-local and is usable in constant expressions.
s is not usable in constant expressions and it satisfies no bullet in the [basic.link] p15, hence s is a non-TU-local entity, what does the value mean? Why do we say the value of s is TU-local?
wrap is defined as a constexpr variable but is not initialized to a TU-local value, hence it is not an exposure as per [basic.link] p15, as well as it is a non-TU-local object. What does the value mean? Why do we say the value of wrap is not TU-local?
For int y = ([]{f();}(),0); , why do we say the declaration is an error? According to [basic.link#14.2], the declaration of y is not an exposure even though it is a non-TU-local entity, It didn't violate [basic.link#17].
Consider [basic.link] p14
A declaration is an exposure if it either names a TU-local entity (defined below), ignoring
- [...]
or defines a constexpr variable initialized to a TU-local value (defined below).
According to [basic.pre] p3 and [basic.link] p16, value and object are different entities, does it mean a variable defined as constexpr that is initialized with a TU-local object is not an exposure?
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
Read the formal example in [basic.link] alongside [basic.link] p14, p15, and p16, and compare the terminology with [basic.pre] p3. Resolve what “value” means for s and wrap and why the declaration of y is ill-formed. Done means the example comments and relevant wording consistently answer each question.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100