Debian Codegraph @

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

raw
1 /* REQUIRED_ARGS: -preview=dip1000
2 TEST_OUTPUT:
3 ---
4 fail_compilation/test20569.d(19): Error: taking address of `scope` variable `s1` with pointers is not allowed in a `@safe` function
5 fail_compilation/test20569.d(23): Error: taking address of `scope` variable `s2` with pointers is not allowed in a `@safe` function
6 ---
7 */
8
9 // https://issues.dlang.org/show_bug.cgi?id=20569
10
11 struct S
12 {
13 int* pointer;
14 }
15
16 void main() @safe
17 {
18 scope S s1;
19 scope int** p1 = &s1.pointer;
20
21 int x;
22 S s2 = S(&x);
23 auto p2 = &s2.pointer;
24 }