On 20 October 2013 20:15, David Nadlinger <[email protected]> wrote: > On Sunday, 20 October 2013 at 18:42:06 UTC, Walter Bright wrote: >> >> If your optimizing compiler is that good, it can optimize "new T[n]" to be >> on the stack as well. > > > Just a side note: LDC actually does this if it can prove statically that the > size is bounded. Unfortunately, the range detection is rather conservative > (unless your allocation size turns out to be a constant due to inlining, > LLVM is unlikely to get it). > > One idea that might be interesting to think about is to insert a run-time > check for the size if an allocation is known not to be escaped, but the size > is not yet determined. As a GC allocation is very expensive anyway, this > probably wouldn't even be much of a pessimization in the general case. >
David, can you check the code generation of: http://dpaste.dzfl.pl/3e333df6 PS: Walter, looks the above causes an ICE in DMD? -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
