[Issue 11826] An Access Violation in Phobos with cartesianProduct at compile-time

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Aug 9 10:00:05 PDT 2014


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

--- Comment #2 from hsteoh at quickfur.ath.cx ---
Managed to reduce it to this near-minimal segfaulting test case:

------
struct MapResult(alias fun, Range)
{
    @property front()
    {
        return fun(0);
    }
}

auto f(R1)(R1 range1)
{
    return MapResult!(a => range1, int[])();
}

auto r = f([2]);

void main() {
    r.front;
}
------

Seems to be a codegen bug; moving the declaration of r inside main() fixes the
problem. Disassembly from inside gdb shows a null pointer dereference inside
the lambda. Not sure exactly what pointer that is yet, but I suspect it's
trying to access the stack frame of f() to get at the parameter 'range1', which
has gone out of scope.

--


More information about the Digitalmars-d-bugs mailing list