d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / test22840.d
blobf7be64afa785059492584196a845b73b9c986aef
1 /* REQUIRED_ARGS: -preview=dip1000
2 * TEST_OUTPUT:
3 ---
4 fail_compilation/test22840.d(25): Error: returning `sb.slice()` escapes a reference to local variable `sb`
5 ---
6 */
8 // inout method with inferred @safe escapes local data
9 // https://issues.dlang.org/show_bug.cgi?id=22840
11 // See also: https://issues.dlang.org/show_bug.cgi?id=20149
13 struct S
15 int buf;
16 auto slice() inout
18 return &buf;
22 int* fun() @safe
24 S sb;
25 return sb.slice(); // should error