Why are void[] contents marked as having pointers?

Lionello Lunesu lio at lunesu.remove.com
Sun May 31 17:46:17 PDT 2009


Denis Koroskin wrote:
> On Sun, 31 May 2009 22:45:23 +0400, Vladimir Panteleev <thecybershadow at gmail.com> wrote:
>  
>> I just went through a ~15000-line project and replaced most occurrences  
>> of void[]. Now the project is an ugly mess of void[], ubyte[] and casts,  
>> but at least it doesn't leak memory like crazy any more.
>>  
>> I don't know why it was decided to mark the contents of void[] as "might  
>> have pointers". It makes no sense!
>>  
>  
> FWIW, I also consider void[] as a storage for an arbitrary untyped binary
 > data, and thus I believe GC shouldn't scan it.

You're contradicting yourself there. void[] is arbitrary untyped data, 
so it could contain uints, floats, bytes, pointers, arrays, strings, 
etc. or structs with any of those.

I think the current behavior is correct: ubyte[] is the new void*.

I also agree that std.file.read (and similar functions) should return 
ubyte[] instead of void[], to prevent surprises after concatenation.

L.



More information about the Digitalmars-d mailing list