Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/test15660.d

raw
1 /* REQUIRED_ARGS: -preview=fixImmutableConv
2 TEST_OUTPUT:
3 ---
4 fail_compilation/test15660.d(26): Error: cannot implicitly convert expression `f(v)` of type `int[]` to `immutable(int[])`
5 fail_compilation/test15660.d(34): Error: cannot copy `const(void)[]` to `void[]`
6 fail_compilation/test15660.d(34): Source data has incompatible type qualifier(s)
7 fail_compilation/test15660.d(34): Use `cast(void[])` to force copy
8 fail_compilation/test15660.d(36): Error: cannot copy `const(int*)[]` to `void[]`
9 fail_compilation/test15660.d(36): Source data has incompatible type qualifier(s)
10 fail_compilation/test15660.d(36): Use `cast(void[])` to force copy
11 ---
12 */
13
14 // https://issues.dlang.org/show_bug.cgi?id=15660
15
16 int[] f(ref void[] m) pure
17 {
18 auto result = new int[5];
19 m = result;
20 return result;
21 }
22
23 void main()
24 {
25 void[] v;
26 immutable x = f(v);
27 }
28
29 // https://issues.dlang.org/show_bug.cgi?id=17148
30 void f(int*[] a, const int*[] b) @system
31 {
32 void[] a1 = a;
33 const(void)[] b1 = b;
34 a1[] = b1[];
35 *a[0] = 0; //modify const data
36 a1[] = new const(int*)[2];
37 }