[Issue 20809] return statement might access memory from destructed temporary
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 17 08:31:29 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=20809
vitamin <submada at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |submada at gmail.com
--- Comment #13 from vitamin <submada at gmail.com> ---
This bug still exists and it depends on existence of dtor in struct:
```d
struct Foo{
int i;
~this()@safe
{
i = 0;
}
}
struct Bar{
int i;
//no dtor!
}
void main()@safe{
scope int* foo = &Foo(1).i; //Compile OK but shouldn't.
scope int* bar = &Bar(1).i; //Error: `Bar(2).i` is not an lvalue and cannot
be modified
}
```
--
More information about the Digitalmars-d-bugs
mailing list