You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constexpr int f() {
int a = 123;
using T = int;
a.~T();
return a; // undefined behavior; previously returned 123
}
static_assert(f() == 123); // ill-formed; previously valid
... but the comments here are wrong: in C++17, pseudo-destruction expressions weren't permitted in constant evaluation at all. This can be fixed by using a runtime example instead of a compile-time one, such as:
int main() {
int a = 123;
using T = int;
a.~T();
return a; // undefined behavior; previously returned 123
}
The text was updated successfully, but these errors were encountered:
P0593R6 adds this example to Annex C:
... but the comments here are wrong: in C++17, pseudo-destruction expressions weren't permitted in constant evaluation at all. This can be fixed by using a runtime example instead of a compile-time one, such as:
The text was updated successfully, but these errors were encountered: