dmd/compiler/test/fail_compilation/test20149.d
2022-07-09 18:53:07 +02:00

34 lines
436 B
D

/* REQUIRED_ARGS: -preview=dip1000
* TEST_OUTPUT:
---
fail_compilation/test20149.d(28): Error: escaping reference to stack allocated value returned by `S('\xff').this(1)`
---
*/
// https://issues.dlang.org/show_bug.cgi?id=20149#c10
@safe:
struct S
{
this(int){ }
char[] opSlice() return
{
return buf[];
}
char[4] buf;
}
S bar();
char[] fun()
{
return S(1)[];
}
void main()
{
auto x = fun();
}