Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -86,6 +86,9 @@ `Issue 57387 `_. - Fix a crash when emitting a concept-related diagnostic. This fixes `Issue 57415 `_. +- Fix a crash when attempting to default a virtual constexpr non-special member + function in a derived class. This fixes + `Issue 57431 `_ Improvements to Clang's diagnostics Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -6954,7 +6954,8 @@ // Define defaulted constexpr virtual functions that override a base class // function right away. // FIXME: We can defer doing this until the vtable is marked as used. - if (M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods()) + if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() && + M->size_overridden_methods()) DefineDefaultedFunction(*this, M, M->getLocation()); if (!Incomplete) Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp =================================================================== --- clang/test/SemaCXX/constant-expression-cxx2a.cpp +++ clang/test/SemaCXX/constant-expression-cxx2a.cpp @@ -1473,3 +1473,13 @@ } static_assert(g()); // expected-error {{constant expression}} expected-note {{in call}} } + +namespace GH57431 { +class B { + virtual int constexpr f() = 0; +}; + +class D : B { + virtual int constexpr f() = default; // expected-error {{only special member functions and comparison operators may be defaulted}} +}; +}