I am on GCC version 8.1.0, and am using the type trait std::is_nothrow_default_constructible_v
to check for throwing destructors (the implementation happens to be using noexcept()
to check for non throwing constructors).
However, I have stumbled upon an interesting phenomenon that might be a compiler bug. I'm asking here for confirmation; here is the minimal reproducible example:
#include <type_traits>
struct B {
~B() noexcept(false) {}
};
struct A {
B b;
~A() noexcept = default;
};
int main()
{
static_assert(std::is_nothrow_default_constructible_v<A>);
return 0;
}
Note that if i do ~A() noexcept {}
instead of ~A() noexcept = default;
, the code compiles as expected.
What is happening here?