Debian Codegraph @

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

raw
1 /*
2 REQUIRED_ARGS: -preview=dip1000
3 TEST_OUTPUT:
4 ---
5 fail_compilation/test22709.d(15): Error: assigning address of variable `local` to `arr` with longer lifetime is not allowed in a `@safe` function
6 fail_compilation/test22709.d(20): Error: assigning address of variable `local` to `arr` with longer lifetime is not allowed in a `@safe` function
7 ---
8 */
9
10 // https://issues.dlang.org/show_bug.cgi?id=22709
11 @safe:
12
13 void escape(ref ubyte[] arr, ref ubyte[64] local)
14 {
15 arr = local[];
16 }
17
18 void escape1(ref ubyte[64] local, ref ubyte[] arr)
19 {
20 arr = local[];
21 }
22
23 ubyte[] getArr()
24 {
25 ubyte[64] blob;
26 ubyte[] arr;
27 escape(arr, blob[]);
28 return arr;
29 }