Reputation: 1616
[expr.const] p9 defines a converted constant expression as:
A converted constant expression of type
T
is an expression, implicitly converted to typeT
, where the converted expression is a constant expression and the implicit conversion sequence contains only [...]
In the following example:
const int a = 42;
int b[a];
The standard does not specify if the conversions applied to a
are part of the evaluation of the expression (in-fact, they are considered to be part of the full-expression, which is the init-declarator), and without specifying this, it effectively means that any glvalue expression of type int
is a converted constant expression, since the conversions are not part of the evaluation of the resulting prvalue (the conversions are applied, resulting in a prvalue, which is then evaluated). Am I wrong, or is this a wording defect?
Upvotes: 0
Views: 129
Reputation: 20579
I think you are being a bit too skeptical here. In my opinion, the “converted expression” unambiguously means the “expression, with the necessary conversions performed.” If you were to interpret as the “expression to be converted,” the past participle “converted” doesn’t feel right. (An alternative might be the “to-be-converted expression.”) So no, I don’t think this is a wording defect.
In this case, the lvalue a
is converted to a prvalue of type int
via the lvalue-to-rvalue conversion, and then converted to a prvalue of type std::size_t
via integral conversions. These are allowed in a constant expression, so the code is fine.
Upvotes: 5