Debian Codegraph @

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

raw
1 /* TEST_OUTPUT:
2 REQUIRED_ARGS: -preview=dip1000
3 ---
4 fail_compilation/test22145.d(115): Error: assigning scope variable `x` to global variable `global` is not allowed in a `@safe` function
5 ---
6 */
7
8 // issues.dlang.org/show_bug.cgi?id=22145
9
10 #line 100
11
12 struct S
13 {
14 int opApply (scope int delegate (scope int* ptr) @safe dg) @safe
15 {
16 return 0;
17 }
18 }
19
20 void test() @safe
21 {
22 static int* global;
23 S s;
24 foreach (scope int* x; s)
25 {
26 global = x;
27 }
28 }