This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-10-11
Consider:
#include <type_traits>
extern "C" int puts(const char*);
struct S {
consteval S(int i) : buf{i} {}
constexpr ~S() {
if (!std::is_constant_evaluated())
puts("Destroyed\n");
}
int buf;
};
int main() {
constexpr S s{43};
return s.buf;
}
The destruction should be manifestly constant-evaluated.
Also consider:
struct A {
constexpr A() {
if !consteval { puts("constructed"); }
}
constexpr ~A() {
if !consteval { puts("destroyed"); }
}
};
void f() {
{ A a; }
delete new A;
A();
}
void g() {
constexpr A a; // Usable in constant expressions: destruction is manifestly constant evaluated.
}
A a; // Constant-initialized, but destruction is not manifestly constant evaluated.
Possible resolution:
Change in 7.7 [expr.const] paragraph 21 as follows:
An expression or conversion is manifestly constant-evaluated if it is:
- ...
- the initializer of a variable that is usable in constant expressions or has constant initialization (6.10.3.2 [basic.start.static])
., [ Footnote: ... ] or [ Example: ... ]- the destruction of an object that is usable in constant expressions and has constant destruction.