On Sat, Jan 31, 2009 at 5:36 PM, amaury pouly <[email protected]> wrote:

> My question is the following: is this a bug of GDC/LDC or is this the 
> expected behaviour ? The second solution must always work but I'm unsure 
> about the first one. Indeed, the specification says that a delegate shall not 
> reference a stack parameter which is logical but it says nothing about 
> function arguments.

In D1, returning nested functions from the function that defined them
is undefined behavior.  If you're using DMD1 and it's working, you
just got lucky.  The compilers could detect this better, but more
generally it's a problem of escape analysis and there will always be
cases where they get it wrong.

But in D2, it's legal and will create a closure.  If you're using
DMD2, that's why it's working.

Reply via email to