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

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jan 18 20:38:07 PST 2015


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

sinkuupump at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sinkuupump at gmail.com
          Component|Phobos                      |DMD

--- Comment #4 from sinkuupump at gmail.com ---
Even replacing "taskPool.amap" with "map!"a()".array", it still segfaults.


import std.algorithm;
import std.array;

auto loo(int a, int[] b)
{
    auto inner(int c)
    {
        return a; // debugger caught SEGV at this line
    }
    return b.map!((x) => () => inner(x));
}

void main()
{
    auto res = loo(3, [1,2,3]);
    auto jobs = map!"a()"(res).array; // evaluate eagerly
}


I reduced 'map' version, and found that just returning "() => () => inner()"
and calling it segfaults. IIUC this seems a compiler bug.


auto loo(int a)
{
    auto inner()
    {
        return a; // debugger caught SEGV at this line
    }

    return () => () => inner();
}

void main()
{
    assert(loo(3)()() == 3);
}

--


More information about the Digitalmars-d-bugs mailing list