4 fail_compilation/test15191.d(31): Error: returning `&identity(x)` escapes a reference to local variable `x`
5 fail_compilation/test15191.d(37): Error: returning `&identityPtr(x)` escapes a reference to local variable `x`
6 fail_compilation/test15191.d(43): Error: cannot take address of `ref return` of `identityPtr()` in `@safe` function `addrOfRefTransitive`
7 fail_compilation/test15191.d(43): Error: returning `&identityPtr(x)` escapes a reference to local variable `x`
11 // https://issues.dlang.org/show_bug.cgi?id=15191
12 // https://issues.dlang.org/show_bug.cgi?id=22519
15 ref int foo(return ref int s)
20 int* bar(return ref int s)
25 ref int identity(ref return int x) {return x;}
26 ref int* identityPtr(ref return int* x) {return x;}
28 int* addrOfRefEscape()
34 int** addrOfRefSystem() @system
37 return &identityPtr(x);
40 int** addrOfRefTransitive()
43 return &identityPtr(x);
47 ref int getGlobalInt() {return gInt;}
49 int* addrOfRefGlobal()
51 return &getGlobalInt();