[Issue 3986] New: Struct constructors bypass default initialization of member variables
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 19 16:13:48 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3986
Summary: Struct constructors bypass default initialization of
member variables
Product: D
Version: 2.036
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: wrong-code
Severity: blocker
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: clugdbug at yahoo.com.au
--- Comment #0 from Don <clugdbug at yahoo.com.au> 2010-03-19 16:13:43 PDT ---
If a struct constructor is called implicitly, member variables are
not default initialized. Applies to D2.036 and later.
Here's a simple test case with an assert that fails. (Beware: this test case
doesn't capture the more complex case where one of the members is itself a
struct with a constructor). I'm pretty sure the problem is in declaration.c,
around line 1140.
struct SiberianHamster
{
int rat = 813;
this(string z) { }
}
void main()
{
SiberianHamster basil = "cybil";
assert(basil.rat == 813);
}
--
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