[Bug c++/65174] noexcept() returns true when operator delete with the object that has a throwing destructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65174 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2018-10-17 CC||jason at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #3 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #1) > Hmm, interesting. When the operand of the delete expression is null the > destructor is not invoked, so it can't throw. That's C++11 [expr.delete] p6 If the value of the operand of the delete-expression is not a null pointer value, the delete-expression will invoke the destructor (if any) for the object or the elements of the array being deleted. > It's not obvious to me whether > GCC's result is allowed by the standard or not. The question is whether GCC is correct to determine that the unevaluated operand of the noexcept operator will not invoke a destructor. Although it's true that it won't throw, deciding that seems to involve some evaluation of the unevaluated operand.
[Bug c++/65174] noexcept() returns true when operator delete with the object that has a throwing destructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65174 --- Comment #1 from Jonathan Wakely redi at gcc dot gnu.org --- Hmm, interesting. When the operand of the delete expression is null the destructor is not invoked, so it can't throw. It's not obvious to me whether GCC's result is allowed by the standard or not.
[Bug c++/65174] noexcept() returns true when operator delete with the object that has a throwing destructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65174 --- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org --- FWIW clang and EDG both fail the first two static assertions here, while GCC passes all three: struct foo { ~foo() throw(int) {} }; int main() { static_assert( noexcept(delete static_castfoo*(nullptr)), ); static_assert( noexcept(delete static_castfoo*(0)), ); static_assert( !noexcept(delete (1+static_castfoo*(0))), ); }