public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration
@ 2020-09-19 20:37 warp at iki dot fi
  2020-10-26 17:19 ` [Bug c++/97121] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: warp at iki dot fi @ 2020-09-19 20:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97121
           Summary: ICE (segfault) on incorrect default three-way
                    comparison declaration
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: warp at iki dot fi
  Target Milestone: ---

Consider the following code (which mistakenly tries to return 'bool' from the
three-way comparison rather than 'auto'):

//----------------------------------------------------------
#include <compare>

class MyClass
{
    int mValue;

 public:
    MyClass(int value): mValue(value) {}

    bool operator<=>(const MyClass&) const = default;
};

int main()
{
    MyClass a = 10, b = 15;
    return (a < b);
}
//----------------------------------------------------------

Trying to compile it causes a segfault:

------------------------------------------------------------
test.cc: In member function ‘constexpr bool MyClass::operator<=>(const
MyClass&) const’:
test.cc:11:10: internal compiler error: Segmentation fault
   11 |     bool operator<=>(const MyClass&) const = default;
      |          ^~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
------------------------------------------------------------

The correct version (ie. with an 'auto' return value) compiles successfully.

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

end of thread, other threads:[~2021-11-04 20:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-19 20:37 [Bug c++/97121] New: ICE (segfault) on incorrect default three-way comparison declaration warp at iki dot fi
2020-10-26 17:19 ` [Bug c++/97121] " mpolacek at gcc dot gnu.org
2021-04-13 17:05 ` redi at gcc dot gnu.org
2021-04-13 17:07 ` redi at gcc dot gnu.org
2021-04-13 17:13 ` redi at gcc dot gnu.org
2021-04-13 18:43 ` cvs-commit at gcc dot gnu.org
2021-11-04 20:52 ` redi 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).