Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/array-conv5.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 list-initialization sequences
5 int b(int (&&)[] ) { return 1; } // #1
6 int b(long (&&)[] ) { return 2; } // #2
7 int b(int (&&)[1]) { return 3; } // #3
8 int b(long (&&)[1]) { return 4; } // #4
9 int b(int (&&)[2]) { return 5; } // #5
10
11 /* Here,
12 -- #1, #3 and #5 should rank better than both #2 and #4, as no promotion
13 is necessitated.
14 -- #1 should rank worse than #3, being far less specialized.
15 -- #1 should rank better than #5, as the latter requires a larger array
16 temporary. (#3 also ranks better than #5 for the same reason--cf. core
17 issue 1307). */
18
19 int
20 main ()
21 {
22 if (b({1}) != 3)
23 __builtin_abort ();
24 }