Safe cast of arrays
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Wed Feb 10 20:01:57 PST 2016
On Wed, 10 Feb 2016 22:39:20 -0500, Steven Schveighoffer wrote:
> I think casting a mutable array to any array type is a recipe for memory
> issues, no matter what is in the elements. Remember that you are casting
> a reference that still has a mutable pointer to it.
>
> @safe should start from a very cautious and overtightened state, and
> then we loosen it as we find issues.
>
> As it was done, it has holes, and so when we fix things, code breaks.
>
> -Steve
I agree with the principle, but it's always safe to read a pointer as if
it were not a pointer, and that's what a cast to an immutable array would
do.
More information about the Digitalmars-d
mailing list