Debian Codegraph @

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

raw
1 /**
2 REQUIRED_ARGS: -preview=dip1000
3 TEST_OUTPUT:
4 ---
5 fail_compilation/test24694.d(25): Error: assigning reference to local variable `x` to non-scope `b.c.p` is not allowed in a `@safe` function
6 ---
7 */
8
9 // https://issues.dlang.org/show_bug.cgi?id=24694
10
11 class C
12 {
13 int* p;
14 }
15
16 struct S
17 {
18 C c;
19 }
20
21 int* escape() @safe
22 {
23 int x = 0;
24 S b = S(new C());
25 b.c.p = &x;
26 return b.c.p;
27 }