[Issue 11211] New: Use of uninitialized struct allowed in a subclass

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 9 13:22:20 PDT 2013


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

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


--- Comment #0 from Max Samukha <samukha at voliacable.com> 2013-10-09 13:22:19 PDT ---
struct S {
    @disable this();

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

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

class A {
    S s;
    this(int x) {
        s = S(1);
    }
}

class B : A {    
    this() {
        s.foo(); // shouldn't compile
        super(1);
    }    
}

void main() {
    auto b = new B;
}

The base class constructor should have been called before the struct can be
accessed in the subclass.

-- 
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