Can we just have struct inheritence already?

Patrick Schluter Patrick.Schluter at bbox.fr
Thu Jun 13 12:20:14 UTC 2019


On Thursday, 13 June 2019 at 10:25:02 UTC, aliak wrote:
> Here's a more detailed "beware of these guys" 
> https://gankro.github.io/blah/only-in-rust/#honorable-mention-zero-sized-types-zsts
>
> "However, in low level (unsafe) code zero-sized types can be a 
> bit hazardous, for two reasons:
>
> If you try to malloc some number of zero-sized types naively, 
> you'll pass an allocation size of 0 to the allocator, which is 
> implementation-defined at best. Also you want to avoid 
> allocating these things anyway!
>
Especially if you use C allocation realloc() as calling it with 
size 0 is synonymous to free(). Ouch!



More information about the Digitalmars-d mailing list