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
[C++20] Destroying delete and deleted destructors (llvm#118800)
When a destroying delete overload is selected, the destructor is not
automatically called. Therefore, the destructor can be deleted without
causing the program to be ill-formed.
Fixesllvm#46818
// noexcept should return false here because the destroying delete itself is a
32
31
// potentially throwing function.
33
32
static_assert(!noexcept(delete(pn)));
33
+
34
+
35
+
structA {
36
+
virtual~A(); // implicitly noexcept
37
+
};
38
+
structB : A {
39
+
voidoperatordelete(B *p, std::destroying_delete_t) { throw"oh no"; } // expected-warning {{'operator delete' has a non-throwing exception specification but can still throw}} \
40
+
expected-note {{deallocator has a implicit non-throwing exception specification}}
41
+
};
42
+
A *p = new B;
43
+
44
+
// Because the destructor for A is virtual, it is the only thing we consider
45
+
// when determining whether the delete expression can throw or not, despite the
46
+
// fact that the selected operator delete is a destroying delete. For virtual
47
+
// destructors, it's the dynamic type that matters.
0 commit comments