aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/spaceship-narrowing1.C
blob: 9f2ff3ceae4cc0634e3660c3dfa817cf62db85d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// PR c++/94058
// { dg-do compile { target c++20 } }

namespace std {
struct strong_ordering {
  int _v;
  constexpr strong_ordering (int v) :_v(v) {}
  constexpr operator int (void) const { return _v; }
  static const strong_ordering less;
  static const strong_ordering equal;
  static const strong_ordering greater;
};
constexpr strong_ordering strong_ordering::less = -1;
constexpr strong_ordering strong_ordering::equal = 0;
constexpr strong_ordering strong_ordering::greater = 1;
}

struct A {
  __INT64_TYPE__ i : 48;
  auto operator <=> (const A&) const = default;
};

struct B {
  long i : 8;
  auto operator <=> (const B&) const = default;
};

void
f (B b)
{
   (void) int{b.i};  // Not narrowing anymore
   b.i <=> b.i;  // Not narrowing anymore
   b <=> b;  // Not deleted anymore
}