[Bug c++/57645] New: Explicitly-declared destructor with no exception specification is always noexcept(true)

travis at gockelhut dot com gcc-bugzilla@gcc.gnu.org
Wed Jun 19 05:08:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57645

            Bug ID: 57645
           Summary: Explicitly-declared destructor with no exception
                    specification is always noexcept(true)
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: travis at gockelhut dot com

#include <type_traits>

struct Thrower
{
    ~Thrower() noexcept(false) { throw 1; }
};

struct Explicit
{
    ~Explicit() {}

    Thrower t;
};
static_assert(!std::is_nothrow_destructible<Explicit>::value, "Explicit");


This will fail on the static_assert in 4.8, in contrast to §15.4.14:

> ..If f is an...destructor...it's implicit exception-specification specifies...f has the exception-specification noexcept(true) if every function it directly invokes allows no exceptions.

And Thrower::~Thrower is directly invoked according to §12.4.8:

> After executing the body of the destructor and destroying any automatic objects allocated within the body, a destructor for class X calls the destructors for X’s direct non-variant non-static data members...


More information about the Gcc-bugs mailing list