| 1 |
/* TEST_OUTPUT: |
| 2 |
--- |
| 3 |
fail_compilation/issue20704.d(17): Error: cannot create default argument for `ref` / `out` parameter from constant `0` |
| 4 |
fail_compilation/issue20704.d(28): Error: template instance `issue20704.f2!int` error instantiating |
| 5 |
fail_compilation/issue20704.d(19): Error: cannot create default argument for `ref` / `out` parameter from constant `0` |
| 6 |
fail_compilation/issue20704.d(30): Error: template instance `issue20704.f4!int` error instantiating |
| 7 |
fail_compilation/issue20704.d(17): Error: cannot create default argument for `ref` / `out` parameter from expression `S(0)` because it is not an lvalue |
| 8 |
fail_compilation/issue20704.d(36): Error: template instance `issue20704.f2!(S)` error instantiating |
| 9 |
fail_compilation/issue20704.d(17): Error: cannot create default argument for `ref` / `out` parameter from expression `null` because it is not an lvalue |
| 10 |
fail_compilation/issue20704.d(38): Error: template instance `issue20704.f2!(C)` error instantiating |
| 11 |
--- |
| 12 |
*/ |
| 13 |
|
| 14 |
// https://issues.dlang.org/show_bug.cgi?id=20704 |
| 15 |
|
| 16 |
void f1(T)(const auto ref T arg = T.init) {} |
| 17 |
void f2(T)(const ref T arg = T.init) {} |
| 18 |
void f3(T)(const auto ref T arg = 0) {} |
| 19 |
void f4(T)(const ref T arg = 0) {} |
| 20 |
|
| 21 |
struct S { int _; } |
| 22 |
class C { int _; } |
| 23 |
|
| 24 |
void main () |
| 25 |
{ |
| 26 |
int i; |
| 27 |
f1!int(i); |
| 28 |
f2!int(i); |
| 29 |
f3!int(i); |
| 30 |
f4!int(i); |
| 31 |
f1!int(); |
| 32 |
f2!int(); |
| 33 |
f3!int(); |
| 34 |
f4!int(); |
| 35 |
f1!S(); |
| 36 |
f2!S(); |
| 37 |
f1!C(); |
| 38 |
f2!C(); |
| 39 |
} |