[Issue 3986] Struct constructors bypass default initialization of member variables

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3986

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|2.036   |D2

--


[Issue 3986] Struct constructors bypass default initialization of member variables

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3986


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #3 from Don clugd...@yahoo.com.au 2010-04-10 12:45:32 PDT ---
Fixed DMD2.043.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3986] Struct constructors bypass default initialization of member variables

2010-03-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3986


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com


--- Comment #2 from Walter Bright bugzi...@digitalmars.com 2010-03-27 
00:34:11 PDT ---
changeset 421

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3986] Struct constructors bypass default initialization of member variables

2010-03-20 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3986


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

   Keywords||patch


--- Comment #1 from Don clugd...@yahoo.com.au 2010-03-20 00:26:22 PDT ---
PATCH: In VarDeclaration::semantic, it should be doing a blit of the default
initializer before it calls the constructor.
Currently it only does that for explicit constructor calls.
This bug as a blocker, since it makes struct invariants unusable: if a struct
with a class invariant is used as a member of another struct, the invariant
will fail on first use of that struct.


Index: declaration.c
===
--- declaration.c(revision 418)
+++ declaration.c(working copy)
@@ -1139,6 +1139,14 @@
// Rewrite as e1.ctor(arguments)
 Expression *ector = new DotIdExp(loc, e1, Id::ctor);
 ei-exp = new CallExp(loc, ector, ei-exp);
+/* Before calling the constructor, initialize
+ * variable with a bit copy of the default
+ * initializer
+ */
+Expression *e = new AssignExp(loc, e1, t-defaultInit(loc));
+e-op = TOKblit;
+e-type = t;
+ei-exp = new CommaExp(loc, e, ei-exp);
 } 
 else
 /* Look for opCall

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---