digitalmars.D.bugs - [Issue 15703] New: safe code should not allow certain types of
- via Digitalmars-d-bugs (28/28) Feb 18 2016 https://issues.dlang.org/show_bug.cgi?id=15703
https://issues.dlang.org/show_bug.cgi?id=15703 Issue ID: 15703 Summary: safe code should not allow certain types of array casts 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 Currently, this code compiles: ------- void main() safe { Object[] objs = [ new Object() ]; long[] longs = cast(long[]) objs; longs[0] = 12345; // corrupts the Object reference } ------- It should be illegal to cast an array of types with indirections in safe code. Except perhaps to an array of const, e.g., const(long)[] (reading the indirections should be no problem, but writing to it via an array cast will break safe). --
Feb 18 2016