The [[noreturn]]
attribute can be applied to functions that are not meant to return. For example:
[[noreturn]] void will_throw() { throw std::r
In practice, neither g++, clang nor MSVC consider the [[noreturn]]
attribute as inherited
#include
struct B {
public:
[[noreturn]] virtual void f() { std::cout << "B\n"; throw 0; }
};
struct D : public B {
void f() override { std::cout << "D\n"; }
};
int main()
{
try { B{}.f(); } catch(...) {}
D{}.f();
B* d = new D{};
d->f();
}
which prints out "B", "D" and "D" for all three compilers.