[Issue 14306] Wrong codegen with -inline for generic lambdas

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Mar 20 00:18:09 PDT 2015


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

--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
Even more reduced:
------------------
struct MapResult(alias fun)
{
    void front()
    {
        fun(1);
    }
}

void bar(R)(R r)
{
    foreach (i; 0..100)
    {
    r.front();
    }
}

struct S {
    int x;
    int bump() { ++x; return x; }
}

void fun(ref S s) {
    MapResult!(x => s.bump())().bar; // fails
//    MapResult!((int x) => s.bump())().bar; // succeeds


    if (s.x != 100) assert(0);
}

void main() {
    S s;
    fun(s);
}
-------------
The failure stems from front() getting inlined. Not sure yet what the problem
is.

--


More information about the Digitalmars-d-bugs mailing list