digitalmars.D.bugs - [Issue 15704] New: safe code should not allow copying of void[]
- via Digitalmars-d-bugs (28/28) Feb 18 2016 https://issues.dlang.org/show_bug.cgi?id=15704
https://issues.dlang.org/show_bug.cgi?id=15704 Issue ID: 15704 Summary: safe code should not allow copying of void[] Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: hsteoh quickfur.ath.cx ----- void main() safe { Object[] objs = [ new Object() ]; void[] arr1 = objs; void[] arr2 = [ 123, 345, 567 ]; arr1[] = arr2[]; // overwrites pointers with arbitrary ints } ----- It should be illegal to copy the contents of one void[] to another void[], since void[] by definition is a type-erased array and can represent any arbitrary type, including types with indirections. Since type information has been erased, there is no way to verify that the destination array has no indirections, so to guarantee safety, such an operation must not be allowed in safe code. --
Feb 18 2016