public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/116428] New: Redeclaration of explicitly defaulted comparison operator makes it undefined
@ 2024-08-20  9:00 fchelnokov at gmail dot com
  2024-08-20 16:01 ` [Bug c++/116428] defaulted friend comparison operator and redeclaration makes it not "defined" pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: fchelnokov at gmail dot com @ 2024-08-20  9:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116428

            Bug ID: 116428
           Summary: Redeclaration of explicitly defaulted comparison
                    operator makes it undefined
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program
```
struct A {
    friend constexpr bool operator ==(const A &, const A &) noexcept = default;
};

constexpr bool operator ==(const A &, const A &) noexcept;
static_assert( A{} == A{} );
```
looks valid and it is accepted by EDG compiler. But GCC rejects it with the
error

> inline function 'constexpr bool operator==(const A&, const A&)' used but never defined

Clang unfortunately has a similar issue.

Online demo: https://gcc.godbolt.org/z/f5saeGrGM

Related discussion: https://stackoverflow.com/q/78889523/7325599

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/116428] defaulted friend comparison operator and redeclaration makes it not "defined"
  2024-08-20  9:00 [Bug c++/116428] New: Redeclaration of explicitly defaulted comparison operator makes it undefined fchelnokov at gmail dot com
@ 2024-08-20 16:01 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-20 16:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116428

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
            Summary|Redeclaration of explicitly |defaulted friend comparison
                   |defaulted comparison        |operator and redeclaration
                   |operator makes it undefined |makes it not "defined"
   Last reconfirmed|                            |2024-08-20

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. Looks like GCC loses it was defaulted.
having a full definition rather than defaulted allows it to work.
Also note it is only the friend definition which was defaulted where GCC loses
it was defaulted.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-20 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-20  9:00 [Bug c++/116428] New: Redeclaration of explicitly defaulted comparison operator makes it undefined fchelnokov at gmail dot com
2024-08-20 16:01 ` [Bug c++/116428] defaulted friend comparison operator and redeclaration makes it not "defined" pinskia at gcc dot gnu.org

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).