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

            Bug ID: 96064
           Summary: Defaulted constexpr spaceship operator triggers
                    internal compiler error after including utility
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: milasudril at gmail dot com
  Target Milestone: ---

The following code crashes gcc-10.1

#include <utility>

class WrappedValue
{
    public:
        constexpr explicit WrappedValue(double val): m_value{val}{}

        constexpr bool operator<=>(WrappedValue const&) const = default

        constexpr double value() const
        {return m_value; }

    private:
        double m_value;
};

Any of the following actions prevents the crash:

 * Remove `#include <utility>`
 * Make `operator<=>` non-constexpr
 * Make `operator<=>` non-defaulted


Error log:

<source>: In member function 'constexpr bool WrappedValue::operator<=>(const
WrappedValue&) const':

<source>:8:24: internal compiler error: Segmentation fault

    8 |         constexpr bool operator<=>(WrappedValue const&) const =
default;

      |                        ^~~~~~~~

Please submit a full bug report,

with preprocessed source if appropriate.

See <https://gcc.gnu.org/bugs/> for instructions.

Compiler returned: 1


On compiler explorer: https://gcc.godbolt.org/z/mo7HkG

Reply via email to