New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is the constructor call a prvalue and what's the type of it? #4837
Comments
IMHO the item "expression" used in [intro.execution] p5 is only used for definition of full-expression. However, one can argue that the definition in [expr.comma] p1 is the definition of the grammar production. The "definition" of "expression" looks like the sentence in [expr.pre] p1 (which also excludes constructor calls), but it's in a non-normative note. |
Note "is considered to be an expression for the purposes of this definition." So, this only refers to "this definition", which is the definition of "full-expression". A constructor call is always caused by some language construct, e.g. an explicit type conversion, and I believe we do specify the value category in those situations. (If there is anything amiss, please be specific.) I don't see a defect here. |
@jensmaurer Consider this example struct A{
A() = default;
A(int){}
};
A t = A(0); //#1 According to [expr.type.conv#2], [expr.cast],
the initialization occurs in A t(0); We do specify the value category and type for the expression |
Again, the mention of expression near the full-expression definition is just for the purposes of defining full-expression, and the wording says so. In your example above, the value category is only relevant for the expressions |
@jensmaurer Assume we're checking whether the full-expression of the initialization is a constant expression The constant expression is defined as
In the above example, if we modify |
Which "the constant expression"? Which expression are you looking at? |
struct A{
A() = default;
constexpr A(int){}
};
constexpr A t = A(0); //#1 According to [dcl.constexpr] p10, the full-expression of the initialization at |
[intro.execution] p5
Hence, the implicit call of a constructor should be considered as an expression.
[class.ctor.general] p2
As well, some rules in the standard also imply a constructor call is used to initialize an object, such as
Hence, the constructor call should be categorized to prvalue as per [basic.lval] p1
However, in the current standard, there is no common rule that phrases what's the type of a constructor call(i.e. what's the type of that prvalue). Furthermore, after the amending of #4737, this issue seems to become more obscure.
The text was updated successfully, but these errors were encountered: