[Issue 9019] New: invariant does not compile/run if class does not define constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 13 16:34:54 PST 2012


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

           Summary: invariant does not compile/run if class does not
                    define constructor
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-11-13 16:34:53 PST ---
class C
{
    invariant()
    {
        assert(0);
    }
}

void main()
{
    C c = new C();  // should fail after ctor invoked
}

C has an implicitly generated constructor, but the invariant isn't compiled or
it doesn't run. If you add an explicit empty constructor then it does get
added.

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