D-Programming-Language/dmd — pull request #1809 by ibuclaw (2013-03-28 20:27:30+00:00)
Title: Use the GC to determine whether delegate was stack or heap allocated in test7290.

This test looks at the address of the delegate, and infers locality based the value of that address. Unfortunately this method is extremely fragile, and is implementation specific.

What it does not even consider is the following may happen under optimisations that causes any of the tests to fail:
* The compiler may inline the functions.
* The compiler may omit the frame pointer.
* The compiler may lazily push the local vars onto the stack only at the point where it's address/value is read, and not in a top down fashion in order of when defined.

The most portable and reliable way to determine that ```scope dg``` does not create a closure is to check that it's address is not referenced in memory allocated by the GC.