gcc/testsuite/gdc.test/fail_compilation/fail21868b.d
raw| 1 | /* REQUIRED_ARGS: -preview=dip1000 |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/fail21868b.d(19): Error: escaping a reference to parameter `s` by returning `&s.x` is not allowed in a `@safe` function |
| 5 | fail_compilation/fail21868b.d(17): perhaps change the `return scope` into `scope return` |
| 6 | --- |
| 7 | */ |
| 8 | |
| 9 | // https://issues.dlang.org/show_bug.cgi?id=21868 |
| 10 | |
| 11 | struct S |
| 12 | { |
| 13 | int x; |
| 14 | int* y; |
| 15 | } |
| 16 | |
| 17 | int* test(ref return scope S s) @safe |
| 18 | { |
| 19 | return &s.x; |
| 20 | } |