Debian Codegraph @

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

raw
1 /*
2 * TEST_OUTPUT:
3 ---
4 fail_compilation/test15672.d(17): Error: cast from `void[]` to `byte[]` is not allowed in a `@safe` function
5 fail_compilation/test15672.d(17): `void` data may contain pointers and target element type is mutable
6 fail_compilation/test15672.d(27): Error: cast from `void*` to `byte*` is not allowed in a `@safe` function
7 fail_compilation/test15672.d(27): `void` data may contain pointers and target element type is mutable
8 ---
9 */
10 // https://issues.dlang.org/show_bug.cgi?id=15672
11
12 alias byte T;
13 alias const(byte) CT;
14
15 @safe T[] test1(void[] a)
16 {
17 return cast(T[])a;
18 }
19
20 @safe CT[] test2(void[] a)
21 {
22 return cast(CT[])a;
23 }
24
25 @safe T* test3(void* a)
26 {
27 return cast(T*)a;
28 }
29
30 @safe CT* test4(void* a)
31 {
32 return cast(CT*)a;
33 }
34
35 @safe T[] test5()
36 {
37 return cast(T[])[];
38 }