mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
37 lines
536 B
D
37 lines
536 B
D
/*
|
|
REQUIRED_ARGS: -preview=dip1000
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/fail19965.d(36): Error: assigning address of variable `f` to `a` with longer lifetime is not allowed in a `@safe` function
|
|
---
|
|
*/
|
|
|
|
// https://issues.dlang.org/show_bug.cgi?id=19965
|
|
|
|
struct Buffer
|
|
{
|
|
int[10] data;
|
|
|
|
int[] getData() @safe return
|
|
{
|
|
return data[];
|
|
}
|
|
}
|
|
|
|
struct Foo()
|
|
{
|
|
Buffer buffer;
|
|
|
|
int[] toArray() @safe return
|
|
{
|
|
return buffer.getData;
|
|
}
|
|
}
|
|
|
|
int[] a;
|
|
|
|
void main() @safe
|
|
{
|
|
Foo!() f;
|
|
a = f.toArray;
|
|
}
|