Debian Codegraph @

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

raw
1 // PR c++/91364 - Implement P0388R4: Permit conversions to arrays of unknown bound.
2 // { dg-do compile { target c++17 } }
3 // { dg-options "-Wpedantic" }
4
5 // The other direction: converting from int[] to int(&)[3] is forbidden.
6
7 extern int a[];
8 extern int (*b)[];
9 extern int (&c)[];
10 int (&y)[] = a;
11 int (&x)[3] = y; // { dg-error "cannot bind reference" }
12 int (&z)[3] = a; // { dg-error "cannot bind reference" }
13
14 void f(int (*)[3]);
15 void f2(int (&)[3]);
16
17 void
18 test ()
19 {
20 f(b); // { dg-error "cannot convert" }
21 f2(c); // { dg-error "cannot bind reference" }
22 }