Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/spaceship-narrowing1.C

raw
1 // PR c++/94058
2 // { dg-do compile { target c++20 } }
3
4 namespace std {
5 struct strong_ordering {
6 int _v;
7 constexpr strong_ordering (int v) :_v(v) {}
8 constexpr operator int (void) const { return _v; }
9 static const strong_ordering less;
10 static const strong_ordering equal;
11 static const strong_ordering greater;
12 };
13 constexpr strong_ordering strong_ordering::less = -1;
14 constexpr strong_ordering strong_ordering::equal = 0;
15 constexpr strong_ordering strong_ordering::greater = 1;
16 }
17
18 struct A {
19 __INT64_TYPE__ i : 48;
20 auto operator <=> (const A&) const = default;
21 };
22
23 struct B {
24 long i : 8;
25 auto operator <=> (const B&) const = default;
26 };
27
28 void
29 f (B b)
30 {
31 (void) int{b.i}; // Not narrowing anymore
32 b.i <=> b.i; // Not narrowing anymore
33 b <=> b; // Not deleted anymore
34 }