Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

What is "the full-expression of its initialization"? CWG3009 #4798

Copy link
Copy link
Open
@xmh0511

Description

@xmh0511
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cwgIssue must be reviewed by CWG.Issue must be reviewed by CWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.Issue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.