gcc/testsuite/gdc.test/fail_compilation/test24680.d
raw| 1 | /** |
| 2 | REQUIRED_ARGS: -preview=dip1000 |
| 3 | TEST_OUTPUT: |
| 4 | --- |
| 5 | fail_compilation/test24680.d(19): Error: escaping a reference to local variable `buf` by returning `c.peek(buf[])` is not allowed in a `@safe` function |
| 6 | --- |
| 7 | */ |
| 8 | |
| 9 | // https://issues.dlang.org/show_bug.cgi?id=24680 |
| 10 | |
| 11 | class C |
| 12 | { |
| 13 | final auto peek(ubyte[] buf) { return buf; } |
| 14 | } |
| 15 | |
| 16 | @safe escape(C c) |
| 17 | { |
| 18 | ubyte[5] buf; |
| 19 | return c.peek(buf[]); |
| 20 | } |