[Issue 23739] Can't return by ref from opApply iteration
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 25 00:47:20 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23739
timon.gehr at gmx.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |safe
--- Comment #1 from timon.gehr at gmx.ch ---
This bug can cause memory corruption in @safe code:
---
struct S{
int* x;
int opApply(scope int delegate(ref int* x)@safe dg)@safe{
return dg(x);
}
}
ref int* foo(ref S s)@safe{
foreach(x;s)
return x;
assert(0);
}
void main()@safe{
auto s=new S;
*foo(*s)=2; // segfault
}
---
--
More information about the Digitalmars-d-bugs
mailing list