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
[expr.const] "converted expression is a constant expression" #4856
Comments
In my view, the phrasing |
Presumably, the intent should be that meaning. However, when we say "X" (shall)is a constant expression, we just concern about whether "X" itself satisfies the requirements to be a constant expression. Such as static int value = random(); //#1
constexpr int& rf = value; // #2 As per [dcl.constexpr] p10
In this example, we require the full-expression of the initialization at As you said, we should consider the process of the initialization in this context, however, if we use the way of interpreting "X shall(is) a constant expression" to interpret "converted expression", as aforementioned, it seems a bit contradict, and "converted expression is a constant expression" actually may not expound the intent that we should check the emulated initialization imposing on that prvalue("converted expression"). In other words, we need to inspect what will happen(evaluate) in the whole implicit conversion that converts the source language construct to the expected target one, the "converted expression" is just the result after performing that sequence of these evaluations, we cannot recall the whole process just through the result, it is a bit philosophical utterance but is true. Maybe, change it to that will be more clear
Then evaluate this constant-expression will be equivalent to performing the corresponding declaration and initialization. |
I suppose you shouldn't think in the way that "considers a variable definition an expression". It's obvious that IMO conversions and object/reference initializations need different "interpretations" when determining whether they are constant. And it is more consistent for me to include "expression s (grammar productions) plus needed implicit conversions to target types" into expressions. |
They're arguably equivalent.
Isn't that what contents I claimed to improve in this issue? I prefer to interpret the implicit conversion as a constant-expression, and evaluate this constant-expression can view what stuff the implicit conversion needs to evaluate. Since we have used a similar utterance to expound "full-expression of the initialization". According to [conv#general-6], the evaluation of this constant-expression would equal to perform the initialization in the declaration T t = E; This proposal may make these rules consistent. |
IMO it's better to specify expressions, constant expressions, and implicit conversions in such way that no additional "interpret" is needed. |
It is impossible to specify conversion to be an expression without "interpret" as if it is an expression of grammar. Moreover, regardless of the category value or type of the conversion, they're all specified in [conv#general-6]. Redefine them is redundant. We just lack the relevant phrase about the evaluation of the whole process of the conversion, even though, the whole conversion occurs in that context. |
Since we define the concept about implicit conversion in [conv]
Consider the rule in [expr.const] p10
Is this equivalent to saying, we model a declaration
the
t
is the "converted expression"? Is it equivalent to saying, we require the prvaluet
shall be a constant expression? Which should first satisfy [expr.const] p5. However, as a prvalue, we do not supply a result object for it, how do we retrospect what would evaluate when evaluating the initialization that occurs in the model declaration? Specifically, in this exampleAt
#1
,a
should be a converted constant expression of type bool. The implicit conversion would apply toa
, which is equivalent to model a declaration and perform the initializationThe conv_result is a prvalue, but how do we retrospect the initialization that occurs at
#0
when we do not supply a result object to make the initialization evaluate? It seems if we say thatwill make the meaning more consistent with the definition of implicit conversion. I think this is also suitable for glvalue(converted expression).
The text was updated successfully, but these errors were encountered: