This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118f. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-11-07
(From submission #780.)
Consider:
consteval void undefined();
template <typename T>
struct scope_exit {
T t;
constexpr ~scope_exit() { t(); } // #2
};
scope_exit guard([]() {
undefined(); // # 1
});
#1 is an immediate escalating expression (because undefined is not defined) and ~scope_exit() is instantiated from a constexpr templated entity #2, thus is immediate escalating. Finally, this causes ~scope_exit to be an immediate function.
However, destructors cannot be consteval.
Proposed resolution (approved by CWG 2025-11-04):
Change in 7.7 [expr.const] paragraph 26 as follows:
An immediate-escalating function is
- the call operator of a lambda that is not declared with the consteval specifier,
- a defaulted special member function that is not declared with the consteval specifier, or
- a function that is not a prospective destructor and that results from the instantiation of a templated entity defined with the constexpr specifier.