Here's a lovely Saturday morning exercise for you D aficionados out
there:

        struct S(alias fun)
        {
            auto g() { return fun(0); }
        }

        auto f(int arr)
        {
            return S!(a => arr)();
        }

        auto r = f(2);

        void main() {
            r.g();
        }

This causes a segfault at runtime. Moving the declaration of r inside
main() fixes the problem. Why?

        https://issues.dlang.org/show_bug.cgi?id=11826

My suspicion is that the lambda is trying to access the local variable
'arr', which has gone out of scope.


T

-- 
Leather is waterproof.  Ever see a cow with an umbrella?

Reply via email to