gcc/testsuite/gdc.test/fail_compilation/retscope5.d
raw| 1 | /* |
| 2 | REQUIRED_ARGS: -preview=dip1000 |
| 3 | */ |
| 4 | |
| 5 | /* |
| 6 | TEST_OUTPUT: |
| 7 | --- |
| 8 | fail_compilation/retscope5.d(5010): Error: assigning address of variable `t` to `p` with longer lifetime is not allowed in a `@safe` function |
| 9 | --- |
| 10 | */ |
| 11 | |
| 12 | #line 5000 |
| 13 | |
| 14 | // https://issues.dlang.org/show_bug.cgi?id=17725 |
| 15 | |
| 16 | void test() @safe |
| 17 | { |
| 18 | int* p; |
| 19 | struct T { |
| 20 | int a; |
| 21 | } |
| 22 | void escape(ref T t) @safe { |
| 23 | p = &t.a; // should not compile |
| 24 | } |
| 25 | } |