[Issue 18580] std.conv.to!(ubyte[])(void[]) should work
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 9 16:04:25 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18580
--- Comment #5 from Jack Stouffer <jack at jackstouffer.com> ---
(In reply to ag0aep6g from comment #4)
> (In reply to Jack Stouffer from comment #3)
> > Is it unsafe though? In this specific case of void[] to ubyte[] (or vise
> > versa) isn't it ok?
>
> void[] to ubyte[] is unsafe, because anything converts to void[]:
>
> ----
> void f(int*[] p)
> {
> void[] v = p; /* This is considered @safe. Don't even need a cast. */
> ubyte[] b = cast(ubyte[]) v; /* Just as unsafe as `cast(ubyte[]) p`. */
> b[0] = 123; /* Messing with pointers like this is not safe. */
> }
> ----
Well the argument there is that the conversion from p to v should be unsafe,
but not the conversion of v to b.
--
More information about the Digitalmars-d-bugs
mailing list