What is "the full-expression of its initialization"? CWG3009
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
The term full-expression is defined in [basic.exec.intro.execution] p5
A full-expression is
- an unevaluated operand,
- a constant-expression ([expr.const]),
- an immediate invocation ([expr.const]),
- an init-declarator ([dcl.decl]) or a mem-initializer ([class.base.init]), including the constituent expressions of the initializer,
- an invocation of a destructor generated at the end of the lifetime of an object other than a temporary object ([class.temporary]) whose lifetime has not been extended, or
- an expression that is not a subexpression of another expression and that is not otherwise part of a full-expression.
None of the above bullets is related to "initialization". In my opinion, It seems the term "initialization" is a sequence of expressions whose invocations would initialize an entity. Although, "initialization" has no formal definition in the standard. Consider this example
struct A{
constexpr A(int){}
};
struct B{
constexpr B(A const& v):v_(v){}
A v_;
};
constexpr B b = A(0); //#1
According to the definition for full-expression, the full-expression in the declaration at #1 should be its init-declarator(namely, b = A(0)).
The [basic.exec.intro.execution] p5 also says
For an initializer, performing the initialization of the entity (including evaluating default member initializers of an aggregate) is also considered part of the full-expression.
Hence, "the full-expression of its initialization" at #1 refers to the init-declarator? [expr.const] p2 says
the full-expression of its initialization is a constant expression when interpreted as a constant-expression
While the definition for constant expression is defined at [expr.const] p11
A constant expression is either a glvalue core constant expression that refers to an entity that is a permitted result of a constant expression (as defined below), or a prvalue core constant expression whose value satisfies the following constraints
Anyhow, the constant expression should first be an expression on grammar. A full-expression is a concept that is convenient to name a language structure that is not necessary to be an expression. As aforementioned, the full-expression is an init-declarator, how could it be a constant expression?
The full-expression at #1 comprises the implicitly call of B::B(A const& v), temporary materialization conversion on A(0) and the destruction of that temporary object. I think the intent is saying that these expressions should satisfy the requirement of a constant expression. However, the current wording is obscure to read and a bit contradictory. The same issue https://stackoverflow.com/questions/62253964/what-is-full-expression-of-initialization
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 [basic.exec.intro.execution] p5 and [expr.const] p2 and p11, then work through the #1 example and the cited Stack Overflow discussion. Determine how “the full-expression of its initialization” relates to an init-declarator and constant expression, and clarify the standard wording so the relationship is unambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100