https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99495
Bug ID: 99495 Summary: constexpr virtual destructor is used before its definition Product: gcc Version: 11.0 URL: https://godbolt.org/z/GGY6aa Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: oleksandr.koval.dev at gmail dot com Target Milestone: --- I found this while playing with constexpr virtual functions. This code gives "error: 'virtual constexpr Derived2::~Derived2()' used before its definition". Error always refers to the last variable, e.g. if we swap d1 and d2 declarations, it will complain about d1. If x is decalred without constexpr it works fine. struct Base{ constexpr virtual ~Base() = default; virtual int Get() const = 0; // non-constexpr }; struct Derived1 : Base{ constexpr int Get() const override { return 1; } }; struct Derived2 : Base{ constexpr int Get() const override { return 2; } }; constexpr auto GetSum(){ const Derived1 d1; const Derived2 d2; const Base* pb1 = &d1; const Base* pb2 = &d2; return pb1->Get() + pb2->Get(); } constexpr // error int x = GetSum(); // OK if not in constexpr context