[Issue 15704] @safe code should not allow copying into void[]

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 14 08:15:55 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15704

--- Comment #2 from hsteoh at quickfur.ath.cx ---
It's not just writing to void[] that's the problem. Consider:

----
int[] intArr = [ 1,2,3,4,5 ];
void[] voidArr = intArr; // OK, every array converts to void[]
int*[] ptrArr;
ptrArr.length = 5;
ptrArr[] = voidArr[]; // reinterpret intArr as pointers
ptrArr[0] = 1; // oops
----

Basically, *anything* that leads to reinterpretation of something as pointer
values cannot be allowed in @safe.

--


More information about the Digitalmars-d-bugs mailing list