gcc/testsuite/gdc.test/fail_compilation/test17764.d
raw| 1 | /* REQUIRED_ARGS: -preview=dip1000 |
| 2 | * TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/test17764.d(109): Error: assigning scope variable `c` to global variable `global` is not allowed in a `@safe` function |
| 5 | --- |
| 6 | */ |
| 7 | |
| 8 | // https://issues.dlang.org/show_bug.cgi?id=17764 |
| 9 | |
| 10 | #line 100 |
| 11 | |
| 12 | int** global; |
| 13 | |
| 14 | struct S { int** str; } |
| 15 | |
| 16 | void f() @safe |
| 17 | { |
| 18 | int* buf; |
| 19 | S[1] c = S(&buf); |
| 20 | global = c[0].str; /* This should be rejected. */ |
| 21 | } |