public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dacamara.cameron at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/94162] ICE [neg] bad return type in defaulted <=>
Date: Sat, 14 Mar 2020 21:45:00 +0000	[thread overview]
Message-ID: <bug-94162-4-TG8Q3a91ad@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94162-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Cameron <dacamara.cameron at gmail dot com> ---
(In reply to Jakub Jelinek from comment #1)
> It isn't clear to me what exactly disallows it, perhaps
> http://eel.is/c++draft/class.spaceship#2.2
> ?
> For auto return type
> http://eel.is/c++draft/class.spaceship#4
> defines what return type it should have.
> If the explicit return type isn't auto, but is one of the
> std::{strong,weak,partial}_ordering, we don't ICE and accept it, should we
> and what behavior should it have?
> #include <compare>
> struct S {
>   float a;
>   std::strong_ordering operator<=>(const S&) const = default;
> };
> bool b = S{} < S{};
> struct T {
>   std::partial_ordering operator<=>(const T&) const = default;
> };
> bool c = T{} < T{};
> For S, the auto return type would be std::partial_ordering and in the
> generated body we just assume the floats will not be unordered.
> So, for bool, shall it be accepted and handled some way, or shall it be
> deleted, or result in immediate error (ill-formed)?
> What about even weirder types (say float or int * or some arbitrary class)?

As you point out, the standard isn't clear about what to do in the case where
the comparison function does not return 'auto' or any of the comparison type
forms.

Our compiler (MSVC) now opts to issue a diag at the point of definition when a
nonsense return type is specified.  There is, unfortunately, room for
implementation divergence here.

Not ICEing--as we once did--is a good start though :).

  parent reply	other threads:[~2020-03-14 21:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 23:47 [Bug c++/94162] New: " dacamara.cameron at gmail dot com
2020-03-13 10:21 ` [Bug c++/94162] " jakub at gcc dot gnu.org
2020-03-14 21:45 ` dacamara.cameron at gmail dot com [this message]
2020-08-18 13:36 ` mpolacek at gcc dot gnu.org
2020-08-18 13:37 ` mpolacek at gcc dot gnu.org
2020-08-18 13:38 ` mpolacek at gcc dot gnu.org
2020-08-18 13:39 ` mpolacek at gcc dot gnu.org
2021-03-08 16:31 ` jakub at gcc dot gnu.org
2021-03-08 16:32 ` jakub at gcc dot gnu.org
2021-08-05  8:55 ` pinskia at gcc dot gnu.org
2021-08-08 17:56 ` dacamara.cameron at gmail dot com
2021-08-08 21:05 ` pinskia at gcc dot gnu.org
2021-08-09  9:03 ` jakub at gcc dot gnu.org
2021-08-12  7:34 ` cvs-commit at gcc dot gnu.org
2021-08-17  6:25 ` pinskia at gcc dot gnu.org
2023-08-08 15:49 ` arthur.j.odwyer at gmail dot com
2024-06-15  2:23 ` sjames at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94162-4-TG8Q3a91ad@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).