www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12764] New: Disabled struct default construction circumvented


          Issue ID: 12764
           Summary: Disabled struct default construction circumvented when
                    field is written to
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

struct S
     disable this();

    this(string) { }
    int f;

class C
        s.f = 1;  // circumvents default ctor!

    S s;

void main() { }

If we comment out writing to 'f' we get:

test.d(11): Error: constructor test.C.this field s must be initialized in

This should always be emitted unless we explicitly call "s = S(...)" or "s =

May 18 2014