https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110948
Bug ID: 110948 Summary: Incorrect -Winvalid-constexpr on virtual defaulted operator== Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: arthur.j.odwyer at gmail dot com Target Milestone: --- Bug #98712 seems related. // https://godbolt.org/z/eKKxcovEn struct D; struct B { bool operator==(const B&) const; virtual bool operator==(const D&) const; }; struct D : B { bool operator==(const D&) const override = default; }; GCC alone gives this bogus -Winvalid-constexpr warning: <source>: In member function 'virtual constexpr bool D::operator==(const D&) const': <source>:10:10: warning: call to non-'constexpr' function 'bool B::operator==(const B&) const' [-Winvalid-constexpr] 10 | bool operator==(const D&) const override = default; | ^~~~~~~~ <source>:5:10: note: 'bool B::operator==(const B&) const' declared here 5 | bool operator==(const B&) const; | ^~~~~~~~ This is obviously contrived code, but the symptom might indicate that GCC is too eager to pretend that the user actually wrote `constexpr`, in situations where the compiler is merely supposed to make an implicitly defined function constexpr-friendly if possible. The AFAICT-analogous situation with `operator=` instead of `operator==` correctly compiles without warning: https://godbolt.org/z/Mof1qaadr