[Bug c++/115222] gcc ignores noexcept on fields' deconstructors in an union
harald at gigawatt dot nl
gcc-bugzilla@gcc.gnu.org
Sat May 25 12:44:06 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115222
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #5 from Harald van Dijk <harald at gigawatt dot nl> ---
I end up with a different reduced test case that does not involve unions:
template <typename _Tp> _Tp declval() noexcept;
template <typename _Tp>
inline constexpr bool is_nothrow_destructible_v = noexcept(declval<_Tp>());
struct A { ~A() noexcept(false) = delete; };
struct B : A { ~B(); };
static_assert(is_nothrow_destructible_v<B>);
The assertion passes in GCC, fails in clang, but I think clang is right here.
It looks like GCC ignores the deleted destructor for determining whether B's
destructor should be implicitly noexcept, but the wording that Andrew Pinski
referenced in comment #2 says B's destructor is potentially throwing "if any of
the destructors for any of its potentially constructed subobjects has a
potentially-throwing exception specification" without regard to whether those
destructors are deleted.
More information about the Gcc-bugs
mailing list