| 1 |
/* |
| 2 |
https://issues.dlang.org/show_bug.cgi?id=21807 |
| 3 |
|
| 4 |
REQUIRED_ARGS: -de |
| 5 |
TEST_OUTPUT: |
| 6 |
--- |
| 7 |
fail_compilation/test21807.d(11): Deprecation: slice of static array temporary returned by `getSArray()` assigned to longer lived variable `this.str` |
| 8 |
fail_compilation/test21807.d(12): Deprecation: slice of static array temporary returned by `getSArray()` assigned to longer lived variable `this.ca` |
| 9 |
--- |
| 10 |
*/ |
| 11 |
#line 1 |
| 12 |
|
| 13 |
char[12] getSArray() pure; |
| 14 |
|
| 15 |
class Foo |
| 16 |
{ |
| 17 |
string str; |
| 18 |
char[] ca; |
| 19 |
|
| 20 |
this() |
| 21 |
{ |
| 22 |
str = getSArray(); // Should probably be a type error |
| 23 |
ca = getSArray(); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
/* |
| 28 |
TEST_OUTPUT: |
| 29 |
--- |
| 30 |
fail_compilation/test21807.d(117): Error: function `addr` is not callable using argument types `(int)` |
| 31 |
fail_compilation/test21807.d(117): cannot pass rvalue argument `S(0).i` of type `int` to parameter `return ref int b` |
| 32 |
fail_compilation/test21807.d(106): `test21807.addr(return ref int b)` declared here |
| 33 |
--- |
| 34 |
*/ |
| 35 |
#line 100 |
| 36 |
|
| 37 |
struct S |
| 38 |
{ |
| 39 |
int i; |
| 40 |
} |
| 41 |
|
| 42 |
int* addr(return ref int b) |
| 43 |
{ |
| 44 |
return &b; |
| 45 |
} |
| 46 |
|
| 47 |
class Foo2 |
| 48 |
{ |
| 49 |
int* ptr; |
| 50 |
|
| 51 |
this() |
| 52 |
{ |
| 53 |
ptr = addr(S().i); // struct temporary |
| 54 |
} |
| 55 |
} |