gcc/testsuite/gdc.test/fail_compilation/fail9537.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/fail9537.d(26): Error: cannot take address of expression `foo(tuple(1, 2))` because it is not an lvalue |
| 5 | --- |
| 6 | */ |
| 7 | |
| 8 | struct Tuple(T...) |
| 9 | { |
| 10 | T field; |
| 11 | alias field this; |
| 12 | } |
| 13 | |
| 14 | Tuple!T tuple(T...)(T args) |
| 15 | { |
| 16 | return Tuple!T(args); |
| 17 | } |
| 18 | |
| 19 | auto ref foo(T)(auto ref T t) |
| 20 | { |
| 21 | return t[0]; // t[0] is deduced to non-ref |
| 22 | } |
| 23 | |
| 24 | void main() |
| 25 | { |
| 26 | int* p = &foo(tuple(1, 2)); |
| 27 | } |