www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9685] New: Context pointer of struct isn't copied when a closure is passed by alias

http://d.puremagic.com/issues/show_bug.cgi?id=9685

           Summary: Context pointer of struct isn't copied when a closure
                    is passed by alias
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: deadalnix gmail.com


--- Comment #0 from deadalnix <deadalnix gmail.com> 2013-03-10 22:43:49 PDT ---
module structfail;

auto get(alias fun)() {
    struct Foo {
        size_t data;

         property
        auto clone() {
            return Foo(data);
        }
    }

    return Foo(0);
}

void main() {
    uint a = 42;
    auto bar = get!(() => a)();

    auto qux = bar.clone;

    import std.stdio;
    writeln("bar context pointer :", (cast(void**) &bar)[1]);
    writeln("qux context pointer :", (cast(void**) &qux)[1]);
}

qux have a garbage context pointer.

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