Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/array-conv3.C

raw
1 // PR c++/91364 - Implement P0388R4: Permit conversions to arrays of unknown bound.
2 // { dg-do run { target c++20 } }
3
4 // Ranking of reference initialization conversions
5
6 int f(int(&)[]) { return 1; } // (1)
7 int f(int(&)[1]) { return 2; } // (2)
8
9 int h(int(*)[]) { return 1; } // (a)
10 int h(int(*)[1]) { return 2; } // (b)
11
12 // From P0388R4:
13 // (2) and (b) should clearly be better than (1) and (a), respectively,
14 // as the former overloads are more restricted.
15 // (a) should be worse than (b), which is implied by (a) necessitating
16 // a qualification conversion in that case.
17
18 int
19 main ()
20 {
21 int arr[1];
22 if (f(arr) != 2)
23 __builtin_abort ();
24 if (h(&arr) != 2)
25 __builtin_abort ();
26 }