std.file.read returns void[] why?

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 17 14:04:25 PDT 2014


On Thursday, 17 April 2014 at 12:59:20 UTC, Steven Schveighoffer 
wrote:
> It was never possible. You must explicitly cast to void[].
>
> void[] makes actually little sense as the result of whole-file 
> read that allocates. byte[] is at least usable and more 
> accurate. In fact, it's a little dangerous to use void[], since 
> you could assign pointer-containing values to the void[] and it 
> should be marked as NOSCAN (no pointers inside file data).
>
> However, when using the more conventional read(void[]) makes a 
> LOT of sense, since any T[] implicitly casts to void[].
>
> -Steve

void[] will only make sense once you've accepted that 
"void.sizeof == 1".

Well, I guess "void[]" is C++'s "char*" for indiscriminate 
buffers. Speaking of which, does "void*" trigger strict aliasing 
in D? This subject seems like a hot potato no-one wants to touch.


More information about the Digitalmars-d-learn mailing list