[Issue 2306] Scope for dynamic arrays should free memory.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 24 10:19:34 PDT 2008
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..$];
}
--
More information about the Digitalmars-d-bugs
mailing list