www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9465] New: Wrong code for delegate call

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9465

           Summary: Wrong code for delegate call
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: maxim maxim-fomin.ru


--- Comment #0 from Maxim Fomin <maxim maxim-fomin.ru> 2013-02-06 12:53:00 PST
---
import std.stdio;

struct S
{
    int i;
    void bar()
    {
        ++i;
    }
    void foo() immutable
    {
        void delegate() dg1 = &bar;
        dg1(); // comment out to fix

        void delegate() dg2;
        dg2.ptr = cast(void*)&this;
        dg2.funcptr = cast(void function())&S.bar;
        dg2();
    }
}

void main()
{
    immutable S s;
    writeln(s.i);
    s.foo();
    writeln(s.i);
}

Without dg1() call, dmd arranges registers's content correctly. However in
presence of dg1 call it incorrectly rearranges them so that [rex.W callq] calls
this pointer, not function pointer.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9465


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |critical


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 04 2013