public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97934] New: Defaulting <=> breaks other equality operators
@ 2020-11-21 22:09 barry.revzin at gmail dot com
  2020-11-21 22:20 ` [Bug c++/97934] Adding an operator== breaks implicit operator== generation from defaulted <=> mpolacek at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: barry.revzin at gmail dot com @ 2020-11-21 22:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97934
           Summary: Defaulting <=> breaks other equality operators
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Reduced example:

#include <compare>

struct X
{
    auto operator<=>(X const&) const = default;
    auto operator==(int i) const;
};

bool f(X x) {
    return x == x;
}

gcc trunk rejects this saying no matching candidate. The presence of the
unrelated operator== seems to prevent the generation of X::operator==(X const&)
const from the defaulted <=>.

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

* [Bug c++/97934] Adding an operator== breaks implicit operator== generation from defaulted <=>
  2020-11-21 22:09 [Bug c++/97934] New: Defaulting <=> breaks other equality operators barry.revzin at gmail dot com
@ 2020-11-21 22:20 ` mpolacek at gcc dot gnu.org
  2020-11-22  1:59 ` ensadc at mailnesia dot com
  2021-09-23  7:13 ` fchelnokov at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-21 22:20 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-11-21
                 CC|                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1
           Keywords|                            |rejects-valid

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/97934] Adding an operator== breaks implicit operator== generation from defaulted <=>
  2020-11-21 22:09 [Bug c++/97934] New: Defaulting <=> breaks other equality operators barry.revzin at gmail dot com
  2020-11-21 22:20 ` [Bug c++/97934] Adding an operator== breaks implicit operator== generation from defaulted <=> mpolacek at gcc dot gnu.org
@ 2020-11-22  1:59 ` ensadc at mailnesia dot com
  2021-09-23  7:13 ` fchelnokov at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: ensadc at mailnesia dot com @ 2020-11-22  1:59 UTC (permalink / raw)
  To: gcc-bugs

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

ensadc at mailnesia dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ensadc at mailnesia dot com

--- Comment #2 from ensadc at mailnesia dot com ---
Per [class.compare.default]
(http://eel.is/c++draft/class.compare.default#5.sentence-1 ), the == operator
is implicitly generated if the member-specification does not declare *any*
operator==. So the current behavior seems correct?

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

* [Bug c++/97934] Adding an operator== breaks implicit operator== generation from defaulted <=>
  2020-11-21 22:09 [Bug c++/97934] New: Defaulting <=> breaks other equality operators barry.revzin at gmail dot com
  2020-11-21 22:20 ` [Bug c++/97934] Adding an operator== breaks implicit operator== generation from defaulted <=> mpolacek at gcc dot gnu.org
  2020-11-22  1:59 ` ensadc at mailnesia dot com
@ 2021-09-23  7:13 ` fchelnokov at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: fchelnokov at gmail dot com @ 2021-09-23  7:13 UTC (permalink / raw)
  To: gcc-bugs

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

Fedor Chelnokov <fchelnokov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fchelnokov at gmail dot com

--- Comment #3 from Fedor Chelnokov <fchelnokov at gmail dot com> ---
I believe, GCC is correct here as well as other compilers:
https://gcc.godbolt.org/z/4nrdedbGd

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

end of thread, other threads:[~2021-09-23  7:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-21 22:09 [Bug c++/97934] New: Defaulting <=> breaks other equality operators barry.revzin at gmail dot com
2020-11-21 22:20 ` [Bug c++/97934] Adding an operator== breaks implicit operator== generation from defaulted <=> mpolacek at gcc dot gnu.org
2020-11-22  1:59 ` ensadc at mailnesia dot com
2021-09-23  7:13 ` fchelnokov 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).