[Issue 6436] New: Refcounted initialization bug
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Aug  4 13:35:15 PDT 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=6436
           Summary: Refcounted initialization bug
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-08-04 13:35:13 PDT ---
import std.typecons;
struct Foo
{
    struct Payload
    {
        this(ref int bar, int value)
        { 
            bar = value;
            assert(bar == 5);   // ok
        }
    }
    alias RefCounted!(Payload, RefCountedAutoInitialize.yes) Data;
    Data data;
    int bar;
    this(int value) 
    {
        data = Data(bar, value);
        assert(bar == 5);  // throws, it's still 0
    }    
}
void main()
{
    auto foo = Foo(5);
}
import std.typecons;
struct Foo
{
    struct Payload
    {
        this(ref int bar, int value)
        { 
            bar = value;
            assert(bar == 5);   // ok..
        }
    }
    alias RefCounted!(Payload, RefCountedAutoInitialize.yes) Data;
    Data data;
    int bar;
    this(int value) 
    {
        data = Data(bar, value);  // initializes bar to 5
        assert(bar == 5);  // throws, it's still 0
    }    
}
void main()
{
    auto foo = Foo(5);
}
Foo's ctor is called, then Refcounted Payload's ctor is called which
initializes Foo's integer field, but upon return to the Foo ctor the integer
field seems to be reinitialized to 0.
-- 
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