Debian Codegraph @

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

raw
1 /*
2 REQUIRED_ARGS: -m32
3 TEST_OUTPUT:
4 ---
5 fail_compilation/test15703.d(23): Error: cast from `Object[]` to `uint[]` is not allowed in a `@safe` function
6 fail_compilation/test15703.d(23): Target element type is mutable and source element type contains a pointer
7 fail_compilation/test15703.d(25): Error: cast from `object.Object` to `const(uint)*` is not allowed in a `@safe` function
8 fail_compilation/test15703.d(25): Source type is incompatible with target type containing a pointer
9 fail_compilation/test15703.d(28): Error: cast from `uint[]` to `Object[]` is not allowed in a `@safe` function
10 fail_compilation/test15703.d(28): Target element type contains a pointer
11 fail_compilation/test15703.d(44): Error: cast from `int[]` to `S[]` is not allowed in a `@safe` function
12 fail_compilation/test15703.d(44): Target element type is opaque
13 fail_compilation/test15703.d(45): Error: cast from `S[]` to `int[]` is not allowed in a `@safe` function
14 fail_compilation/test15703.d(45): Source element type is opaque
15 ---
16 */
17
18 // https://issues.dlang.org/show_bug.cgi?id=15703
19
20 void test() @safe
21 {
22 auto objs = [ new Object() ];
23 auto longs = cast(size_t[]) objs; // error
24 auto longc = cast(const(size_t)[]) objs; // ok
25 auto longp = cast(const(size_t)*) objs[0]; // error
26
27 size_t[] al;
28 objs = cast(Object[]) al; // error
29
30 auto am = cast(int[])[];
31 }
32
33 void test2() @safe
34 {
35 const(ubyte)[] a;
36 auto b = cast(const(uint[])) a;
37 }
38
39 struct S;
40
41 void opaque() @safe
42 {
43 auto a = [1, 2];
44 S[] b = cast(S[]) a;
45 a = cast(int[]) b;
46 }