[Issue 12839] std.parallelism with nested functions and lambdas. Segfault

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jun 2 04:03:22 PDT 2014


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

--- Comment #1 from John Colvin <john.loughran.colvin at gmail.com> ---
Interestingly, the following works fine. It should be the same as the
lambda-based version, no?

import std.parallelism;
import std.algorithm;

auto loo(int a, int[] b)
{
    auto inner(int c)
    {
        return a;    
    }
    auto wrapper(int x)
    {
        auto wrapperInner()
        {
            return inner(x);
        }
        return &wrapperInner;
    }
    return b.map!wrapper;
}

void main()
{
    defaultPoolThreads = 1;
    auto res = loo(3, [1,2,3]);
    auto jobs = taskPool.map!"a()"(res);
    assert(jobs.front() == 3);
}

--


More information about the Digitalmars-d-bugs mailing list