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

Denis Koroskin 2korden at gmail.com
Mon Aug 25 08:42:55 PDT 2008


On Mon, 25 Aug 2008 02:07:41 +0400, Jarrett Billingsley  
<kb3ctd2 at yahoo.com> wrote:

> <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);
>
>

Stack overflow, do you expect anything else?


More information about the Digitalmars-d-bugs mailing list