aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/test22709.d
blob: dd5258e0b376593c16a526de0333bb7453dc3f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
REQUIRED_ARGS: -preview=dip1000
TEST_OUTPUT:
---
fail_compilation/test22709.d(15): Error: address of variable `local` assigned to `arr` with longer lifetime
fail_compilation/test22709.d(20): Error: address of variable `local` assigned to `arr` with longer lifetime
---
*/

// https://issues.dlang.org/show_bug.cgi?id=22709
@safe:

void escape(ref ubyte[] arr, ref ubyte[64] local)
{
    arr = local[];
}

void escape1(ref ubyte[64] local, ref ubyte[] arr)
{
    arr = local[];
}

ubyte[] getArr()
{
    ubyte[64] blob;
    ubyte[] arr;
    escape(arr, blob[]);
    return arr;
}