mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
25 lines
495 B
D
25 lines
495 B
D
/* REQUIRED_ARGS: -preview=dip1000
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/test18484.d(19): Error: returning `x.bar()` escapes a reference to local variable `x`
|
|
fail_compilation/test18484.d(24): Error: escaping reference to stack allocated value returned by `S(0)`
|
|
---
|
|
*/
|
|
|
|
// https://issues.dlang.org/show_bug.cgi?id=18484
|
|
|
|
struct S
|
|
{
|
|
int* bar() @safe return;
|
|
int i;
|
|
}
|
|
|
|
int* test1() @safe
|
|
{
|
|
auto x = S(); return x.bar(); // error
|
|
}
|
|
|
|
int* test2() @safe
|
|
{
|
|
return S().bar(); // error
|
|
}
|