Safe cast of arrays
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Wed Feb 10 14:49:33 PST 2016
On Wed, 10 Feb 2016 21:40:21 +0000, Iakh wrote:
> On Wednesday, 10 February 2016 at 20:14:29 UTC, Chris Wright wrote:
>> @safe protects you from segmentation faults and reading and writing
>> outside an allocated segment of memory. With array casts, @safety is
>> assured
>
> Yes, @safe protects from direct cast to/from ref types but there still
> is a trick with T[] -> void[] -> T2[] cast:
>
> So no safety in this world.
Okay, that's a problem.
It should always be safe to cast from void[] to immutable(T)[] where T
doesn't contain pointers.
I didn't see a bug for this, so I'm filing it.
More information about the Digitalmars-d
mailing list