[Issue 5737] New: postblit not called for locals initialized from ref functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 15 01:57:31 PDT 2011


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

           Summary: postblit not called for locals initialized from ref
                    functions
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: samukha at voliacable.com


--- Comment #0 from Max Samukha <samukha at voliacable.com> 2011-03-15 01:54:18 PDT ---
struct S
{
    static int destroyed;
    static int copied;

    this(this)
    {
        copied++;
    }

    ~this()
    {
        destroyed++;
    }
}

S s;

ref S foo()
{    
    return s;
}

void main()
{
    {
        auto s2 = foo();        
    }

    assert(S.copied == 1); // fail, s2 was not copied;
    assert(S.destroyed == 1); // ok, s2 was destroyed    
}

The destructor is called on s2, though s2 has not been postblit(ted?).
Maybe the same as other struct lifetime bugs.

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


More information about the Digitalmars-d-bugs mailing list