August 09, 2010 [Issue 4609] New: clear() does not call base constructor if a class does not implement a default constructor | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4609 Summary: clear() does not call base constructor if a class does not implement a default constructor Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: sean@invisibleduck.org ReportedBy: lutger.blijdestijn@gmail.com --- Comment #0 from Lutger <lutger.blijdestijn@gmail.com> 2010-08-09 16:58:36 PDT --- If a class only defines a constructor with one or more parameters and no default constructor, clear() does not call any constructor of the base classes nor does it throw an exception. class A { int n = -1; this() { n = 0; } } class B : A { // uncomment the following line and the unittest will pass // this(){} this(int b) { n = b; } } unittest { auto foo = new B(42); assert( foo.n == 42 ); clear(foo); assert( foo.n == 0 ); //fails } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 09, 2012 [Issue 4609] clear() does not call base constructor if a class does not implement a default constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lutger | http://d.puremagic.com/issues/show_bug.cgi?id=4609 Denis Shelomovskij <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |verylonglogin.reg@gmail.com Resolution| |INVALID --- Comment #1 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-08-09 13:22:39 MSD --- `destroy` (new name of `clear`) shouldn't call constructors at all. It just destroys current object without creatuing a new valid one. Uncommenting constructor in derived class doesn't (and shouldn't) change anything. If it was, that was a bug (disappeared now) in `clear`. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation