https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107512
Bug ID: 107512 Summary: Defaulted virtual destructor not considered in constexpr context Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kacper.slominski72 at gmail dot com Target Milestone: --- The following code causes a compiler error on GCC 12.2 and godbolt's trunk (compiled with "-std=c++20 -Wall -Wextra -Wpedantic"): struct base { constexpr virtual ~base() = default; }; struct derived final : base { constexpr virtual ~derived() = default; }; constexpr derived der; The reported error is: <source>:9:19: error: 'virtual constexpr derived::~derived()' used before its definition 9 | constexpr derived der; | ^~~ Changing the destructor to the following makes the error go away: constexpr virtual ~derived() { } As does making the variable not constexpr. Clang seems to accept this without any problems.