[Bug c++/97216] New: ICE with (incorrect) spaceship operator declaration

GCCBugzilla at DRHouck dot me gcc-bugzilla@gcc.gnu.org
Sun Sep 27 09:42:40 GMT 2020


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

            Bug ID: 97216
           Summary: ICE with (incorrect) spaceship operator declaration
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: GCCBugzilla at DRHouck dot me
  Target Milestone: ---

Created attachment 49275
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49275&action=edit
Tarball of original file (.cpp), preprocessed file (.ii), and compiler output
(.log)

Attempting to compile the following code produces an ICE.  The code may be
ill-formed (I don't know if I'm reading the standard correctly when trying to
figure that out), and if not should probably still generate a warning, but
either way an ICE is not the right output.

Minimized test case, with a commented-out line used in additional notes:

```
#include <compare>

class C
{
public:
        int a;
        constexpr bool operator<=>(C const& other) const = default;
};

// auto b = C{17} <=> C{23};
```

This file, the preprocessed file, and the output from the compiler are
attached.

---

Additional notes from my experimenting, may or may not be useful:
* I can reproduce this on Compiler Explorer trunk, which claims to be version
"11.0.0 20200926 (experimental)", but the answers and log file below are for my
personal machine, which is still on 10.2.0.  Because of this, I am reporting
the bug here, instead of the Arch bug tracker linked in the compiler log.
* Removing the `constexpr` doesnʼt generate any ICE or diagnostic at -Wall
-Wextra, but uncommenting the last line adds back the ICE (referencing line 7,
the declaration, instead of the last line).
* Removing the #include line (with or without the `constexpr`) results in the
no ICE or diagnostic at -Wall -Wextra; uncommenting the last line results in
"error: use of deleted function 'constexpr bool C::operator<=>(const C&)
const'" and "note: 'constexpr bool C::operator<=>(const C&) const' is
implicitly deleted because the default definition would be ill-formed".


Additional details as requested at https://gcc.gnu.org/bugs/:

the exact version of GCC:

g++ (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


the system type: Arch Linux, x86-64
the options given when GCC was configured/built: Included in the -v output
attached
the complete command line that triggers the bug: `g++ -v -save-temps -std=c++2a
-c spaceship_ice.cpp > spaceship_ice.log 2>&1`; the same appears if I use the
attached .ii file.
the compiler output (error messages, warnings, etc.): attached
the preprocessed file (*.i*) that triggers the bug, generated by adding
-save-temps to the complete compilation command: attached


More information about the Gcc-bugs mailing list