Add __builtion_unreachable to vector::size(), vector::capacity()
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail14304.d
blob8321401bcafaa86f5e8d22da2f06ba306adfc786
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail14304.d(26): Error: reinterpreting cast from `const(S14304)*` to `S14304*` is not supported in CTFE
5 fail_compilation/fail14304.d(58): called from here: `sle14304.modify()`
6 fail_compilation/fail14304.d(35): Error: cannot modify read-only constant `[1:1, 2:2]`
7 fail_compilation/fail14304.d(61): called from here: `modify14304(aae14304)`
8 fail_compilation/fail14304.d(41): Error: cannot modify read-only constant `[1, 2, 3]`
9 fail_compilation/fail14304.d(64): called from here: `modify14304(cast(const(int)[])index14304)`
10 fail_compilation/fail14304.d(46): Error: array cast from `immutable(double[])` to `double[]` is not supported at compile time
11 fail_compilation/fail14304.d(67): called from here: `modify14304(cast(const(double)[])slice14304)`
12 fail_compilation/fail14304.d(53): Error: cannot modify read-only string literal `"abc"`
13 fail_compilation/fail14304.d(70): called from here: `modify14304(cast(const(char)[])str14304)`
14 ---
17 struct S14304
19 int x;
21 int modify() const
23 assert(x == 1);
25 // This force modification must not affect to ghe s14304 value.
26 (cast(S14304*)&this).x = 10;
28 assert(x == 10);
29 return x;
32 int modify14304(immutable int[int] aa)
34 auto p = cast(int*)&aa[1];
35 *p = 10;
36 return aa[1];
38 int modify14304(const(int)[] arr)
40 auto a = cast(int[])arr;
41 a[0] = 10;
42 return arr[0];
44 int modify14304(const(double)[] arr)
46 auto a = cast(double[])arr;
47 a[] = 3.14;
48 return cast(int)arr[0];
50 int modify14304(const(char)[] str)
52 auto s = cast(char[])str;
53 s[0] = 'z';
54 return str[0];
57 static immutable sle14304 = immutable S14304(1);
58 static immutable v14304 = sle14304.modify();
60 static immutable aae14304 = [1:1, 2:2];
61 static immutable w14304 = modify14304(aae14304);
63 static immutable index14304 = [1, 2, 3];
64 static immutable x14304 = modify14304(index14304);
66 static immutable slice14304 = [1.414, 1.732, 2];
67 static immutable y14304 = modify14304(slice14304);
69 static immutable str14304 = "abc";
70 static immutable z14304 = modify14304(str14304);