Debian Codegraph @

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

raw
1 /*
2 REQUIRED_ARGS: -preview=dip1000
3 TEST_OUTPUT:
4 ---
5 fail_compilation/test17422.d(23): Error: returning scope variable `p` is not allowed in a `@safe` function
6 ---
7 */
8 struct RC
9 {
10 Object get() return @trusted
11 {
12 return cast(Object) &store[0];
13 }
14
15 private:
16 ubyte[__traits(classInstanceSize, Object)] store;
17 }
18
19 Object test() @safe
20 {
21 RC rc;
22 auto p = rc.get; // p must be inferred as scope variable, works for int*
23 return p;
24 }