public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99628] New: g++ fails to do the implicit conversion when rewritten operator<=>
@ 2021-03-17 15:18 hewillk at gmail dot com
  2021-08-13  0:10 ` [Bug c++/99628] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: hewillk at gmail dot com @ 2021-03-17 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99628
           Summary: g++ fails to do the implicit conversion when rewritten
                    operator<=>
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

gcc-trunk rejects this valid code:

struct S{
  operator int() { return 0; }
};

auto operator<=>(S, S) { return S{}; }

int main() {
  return S{} < S{};
}

(godbolt://godbolt.org/z/9ah1xE)


The expression S{} < S{} would be rewritten as (S{} <=> S{}) < 0, since the
(S{} <=> S{}) return S{}, we compare S{} with 0, and S{} explicit convert to 0,
so we compare 0 < 0 which is false, but gcc-trunk rejects with:

<source>:8:14: error: no match for 'operator<' (operand types are 'S' and
'int')
    8 |   return S{} < S{};

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

* [Bug c++/99628] g++ fails to do the implicit conversion when rewritten operator<=>
  2021-03-17 15:18 [Bug c++/99628] New: g++ fails to do the implicit conversion when rewritten operator<=> hewillk at gmail dot com
@ 2021-08-13  0:10 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-13  0:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-08-13

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

end of thread, other threads:[~2021-08-13  0:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 15:18 [Bug c++/99628] New: g++ fails to do the implicit conversion when rewritten operator<=> hewillk at gmail dot com
2021-08-13  0:10 ` [Bug c++/99628] " 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).