[Issue 20809] return statement might access memory from destructed temporary
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 9 13:36:49 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20809
timon.gehr at gmx.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |timon.gehr at gmx.ch
--- Comment #7 from timon.gehr at gmx.ch ---
While this is a regression, the underlying bug existed already in 2.089.1:
@safe:
struct S{
@safe:
int[8] a;
~this(){ a[] = 0; }
ref val(){ return a; }
}
S bar(){ return S([2,2,2,2,2,2,2,2]); }
int[8] foo(){ return bar.val; }
void main(){ assert(foo() == [2,2,2,2,2,2,2,2]); } // error
I guess this is why review did not catch the problem (the pull request just
generalized an already existing wrong transformation).
--
More information about the Digitalmars-d-bugs
mailing list