Created on 2023-11-08.00:00:00 last changed 24 months ago
(From submission #460.)
Consider:
struct B {
constexpr ~B(){} // #1
};
struct A {
constexpr A(const B&){} // #2
constexpr ~A(){}
};
constexpr A a(B{}); // #3, checks #1 and #2
Subclause 7.7 [expr.const] bullet 6.1 specifies:
A variable v is constant-initializable if
- the full-expression of its initialization is a constant expression when interpreted as a constant-expression...
- ...
However, a full-expression need not satisfy the syntax of a constant-expression, and indeed, for the example at #3, the only syntactical expression is B{}, but the checking of the constructor of A and the destructor of B is intended to be part of the conditions for constant-initializable, which unsuccessfully attempts to delegate to 7.7 [expr.const] paragraph 22.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2023-11-08 00:00:00 | admin | create | |