lundi 29 octobre 2018

Unexplained 'looser throw specifier' error from gcc c++11

The following code when compiled with gcc 5.4.0 displays a 'looser throw specifier error'. I don't see why.

class Err {
};

class A {
    public:
        A() {}
        ~A() throw(Err) {}
};

class Base {
    public:
        inline Base()  { }
        inline virtual ~Base() { }
};

class Derived : public virtual Base {
    public:
        A a;
        Derived() { }
};

int main()
{
    return 0;
}

g++ --std=c++11 -m64 -Wtype-limits -Wextra -ggdb -Wall -Werror looserthrow.cpp -o looserthrow looserthrow.cpp:16:7: error: looser throw specifier for ‘virtual Derived::~Derived() throw (Err)’ class Derived : public virtual Base { ^ looserthrow.cpp:13:24: error: overriding ‘virtual Base::~Base() noexcept’ inline virtual ~Base() { } ^

Aucun commentaire:

Enregistrer un commentaire