[Issue 10921] New: scoped returns a reference to an uninitialized object

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 29 06:59:02 PDT 2013


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

           Summary: scoped returns a reference to an uninitialized object
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            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> 2013-08-29 06:58:59 PDT ---
-----
import std.conv;
import std.typecons;

class Point
{
    this(int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    int x;
    int y;
}

void main()
{
    auto p1 = scoped!Point(1, 2);
    assert(p1.x == 1, p1.x.text);  // ok
    assert(p1.y == 2, p1.y.text);  // ok

    Point p2 = scoped!Point(1, 2);
    assert(p2.x == 1, p2.x.text);  // fails, == 0
    assert(p2.y == 2, p2.y.text);  // fails, == 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