[Issue 4609] New: clear() does not call base constructor if a class does not implement a default constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 9 16:58:39 PDT 2010
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 at invisibleduck.org
ReportedBy: lutger.blijdestijn at gmail.com
--- Comment #0 from Lutger <lutger.blijdestijn at 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: -------
More information about the Digitalmars-d-bugs
mailing list