[Issue 12989] Wrong x86_64 code for delegate return when compiled as lib (-lib)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 8 14:32:44 PDT 2014


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

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
// Attachment 1368 is small enough to inline here:

alias Action = void delegate();

class A
{
    invariant()
    {
    }

    public Action foo(Action a)
    {
        synchronized
        {
            B elements = new B;
            Action[] actions = [a];

            elements.bar(actions);

            if (actions.length > 1)
                elements.bar(actions);
            return actions[0];
        }
        return null;
    }
}

class B
{
    public bool bar(ref Action[])
    {
        return false;
    }
}

class D
{
    void baz()
    {
    }
}

void main()
{
    auto a = new A;
    auto d = new D;

    assert(a.foo(&d.baz) == &d.baz);
}

--


More information about the Digitalmars-d-bugs mailing list