Debian Codegraph @

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

raw
1 /* REQUIRED_ARGS: -preview=dip1000
2 * TEST_OUTPUT:
3 ---
4 fail_compilation/fail17842.d(14): Error: assigning scope variable `p` to non-scope `*q` is not allowed in a `@safe` function
5 fail_compilation/fail17842.d(23): Error: copying scope variable `obj` into allocated memory is not allowed in a `@safe` function
6 ---
7 */
8
9 // https://issues.dlang.org/show_bug.cgi?id=17842
10
11 void* testp(scope void* p) @safe
12 {
13 scope void** q;
14 *q = p; // error
15 void** t;
16 *t = *q;
17 return *t;
18 }
19
20 Object testobj(scope Object obj) @safe
21 {
22 scope Object[] arr;
23 arr ~= obj; // error
24 Object[] array;
25 array ~= arr;
26 return array[0];
27 }