On Sunday, 4 November 2012 at 17:41:19 UTC, Jakob Ovrum wrote:
On Sunday, 4 November 2012 at 17:35:09 UTC, Tommi wrote:
I wonder if it would be possible in D to let the compiler
allocate dynamic arrays on stack when it can statically
guarantee that it's safe to do so (no dangling references,
never increasing the size of the array, etc).
David Nadlinger was talking about how LDC does an optimization
exactly like this, quite recently.
Yes, LDC has an optimization pass like this indeed. However, it
is currently disabled because its implementation causes a
seemingly unrelated, hard-to-diagnose test suite failure. If
anyone is interested in doing a little compiler debugging, here
is the current state:
https://github.com/ldc-developers/ldc/pull/206. I unfortunately
won't be able to work on it in the next few days…
David