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: [email protected]
Reporter: [email protected]
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).
--