[Issue 2306] Scope for dynamic arrays should free memory.

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Aug 24 15:07:41 PDT 2008


<d-bugmail at puremagic.com> wrote in message 
news:g8s576$2ehd$1 at digitalmars.com...
> http://d.puremagic.com/issues/show_bug.cgi?id=2306
>
>
>
>
>
> ------- Comment #1 from 2korden at gmail.com  2008-08-24 12:19 -------
> In fact, it shouldn't allocate in the first place (in my opinion). C99 is 
> able
> to stack-allocate arrays and so should D:
>
> void test(int size)
> {
>    int[size] stackAllocatedStaticArray;
>    scope int[] stackAllocatedDynamicArray = new int[size];
>
>    //exactly the same as the following:
>    // int[size] tmp;
>    // int[] stackAllocatedDynamicArray = tmp[0..$];
> }
>
>
> -- 
>

test(50000000); 




More information about the Digitalmars-d-bugs mailing list