public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110948] New: Incorrect -Winvalid-constexpr on virtual defaulted operator==
@ 2023-08-08 15:43 arthur.j.odwyer at gmail dot com
0 siblings, 0 replies; only message in thread
From: arthur.j.odwyer at gmail dot com @ 2023-08-08 15:43 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-08 15:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-08 15:43 [Bug c++/110948] New: Incorrect -Winvalid-constexpr on virtual defaulted operator== arthur.j.odwyer at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).