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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 14 04:40:53 PST 2012


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


Maxim Fomin <maxim at maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim at maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim at maxim-fomin.ru> 2012-11-14 04:40:52 PST ---
(In reply to comment #0)
> C has an implicitly generated constructor

Why? It seems there is no constructor in case like this. 

> but the invariant isn't compiled or
> it doesn't run. If you add an explicit empty constructor then it does get
> added.

It is compiled but is not run because there is no ctor. The spec says that
invariant is called when ctor completes but it does not say what happens when
there is no ctor. You actually asking either create dummy ctor for cases like
this or call invariant just after allocating class object which is not
efficient - the first call to public function will abort the application
anyway.

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