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

            Bug ID: 92426
           Summary: ICE on spaceship declaration plus other P1185R2
                    interaction issue
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dacamara.cameron at gmail dot com
  Target Milestone: ---

I was playing around with the spaceship operator using gcc10 on godbolt and
discovered an issue trying to compile the following program:

struct Basics {
  int i;
  char c;
  float f;
  double d;
  auto operator<=>(const Basics&) const = default;
};

struct Arrays {
  int ai[1];
  char ac[2];
  float af[3];
  double ad[2][2];
  auto operator<=>(const Arrays&) const = default;
};

struct Bases : Basics, Arrays {
  auto operator<=>(const Bases&) const = default;
};

int main() {
  constexpr Bases a = { { 0, 'c', 1.f, 1. },
                        { { 1 }, { 'a', 'b' }, { 1.f, 2.f, 3.f }, { { 1., 2. },
{ 3., 4. } } } };
  constexpr Bases b = { { 0, 'c', 1.f, 1. },
                        { { 1 }, { 'a', 'b' }, { 1.f, 2.f, 3.f }, { { 1., 2. },
{ 3., 4. } } } };
  static_assert(a == b);
  static_assert(!(a != b));
  static_assert(!(a < b));
  static_assert(a <= b);
  static_assert(!(a > b));
  static_assert(a >= b);
}

The program ultimately ICEs gcc10 but working with a reduced repro shows some
other gaps:

struct Arrays {
    int a[2];
#ifdef MEMBERS
    auto operator<=>(const Arrays&) const = default;
#endif
#ifdef FRIENDS
    friend auto operator<=>(const Arrays&, const Arrays&) = default;
    // friend bool operator==(const Arrays&, const Arrays&) = default; //
should be implicitly declared
#endif
};

int main() {
    constexpr Arrays a1 { 1, 2 };
    constexpr Arrays a2 { 3, 4 };
    static_assert(a1 == a1);  // OK
    static_assert(a1 != a2);  // OK
    static_assert(a1 < a2);   // ICE
}

When MEMBERS is defined it only ICEs at the final static assert, but with
FRIENDS it both leaves the implicitly declared operator== undeclared _and_
ICEs.  Additionally, replacing `auto` with `std::strong_ordering` produces an
ICE in finish_expr_stmt so I assume arrays just aren't handled yet?

Reply via email to