Hole of new? (Re: Array of array)

bearophile bearophileHUGS at lycos.com
Sat Jan 7 10:29:25 PST 2012

Steven Schveighoffer:

> Interesting trivia, the compiler actually transforms the following:
> struct S
> {
>   int x;
> }
> auto s = new S;
> into this:
> auto s = (new S[1]).ptr;
> Found that out when revamping the array allocation code.  It's one thing  
> that still bugs me because this means s will be initialized as an  
> appendable array when it doesn't have to be.

What are the disadvantages caused by this?
If the disadvantages are significant is this improvement in Bugzilla as enhancement request?
Struct heap allocations are important, they are a basic part of D programming.


More information about the Digitalmars-d-learn mailing list