www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11212] New: Use of uninitialized struct allowed 2

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

           Summary: Use of uninitialized struct allowed 2
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: samukha voliacable.com


--- Comment #0 from Max Samukha <samukha voliacable.com> 2013-10-09 14:00:29
PDT ---
Related to issue 11211

struct S {
     disable this();

    bool cted;
    this(int x) {
        cted = true;        
    }

    void foo() {
        assert(cted);
    }
}

void bar(A a) {
    a.s.foo();   
}

class A {
    S s;
    this() {
        bar(this); // shouldn't compile
        s = S(1);
    }
}

void main() {
    auto a = new A;
}

Passing 'this' outside the constructor should be disallowed before structs with
disabled constructors are initialized.

I could go on with bug reports but it is obvious that there is no good solution
 in the face of current compilation model.

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