digitalmars.D.bugs - [Issue 8170] New: Incorrect member initialization in associative array of structs
- d-bugmail puremagic.com (34/34) May 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8170
- d-bugmail puremagic.com (16/37) Sep 22 2013 http://d.puremagic.com/issues/show_bug.cgi?id=8170
http://d.puremagic.com/issues/show_bug.cgi?id=8170 Summary: Incorrect member initialization in associative array of structs Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: juhonurm gmail.com --- The code below throws an assert error: void main() { struct S { void* ptr = null; S opAssign(int) { assert (ptr is null); return this; } } S[int] s; s[0] = 0; } In an associative array, ptr is not initialized to null before opAssign is called. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 30 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8170 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATEThe code below throws an assert error: void main() { struct S { void* ptr = null; S opAssign(int) { assert (ptr is null); return this; } } S[int] s; s[0] = 0; } In an associative array, ptr is not initialized to null before opAssign is called.When you call opAssign directly, it would throw RangeError. S[int] s; s[0].opAssign(0); So the OP code should also throw RangeError. *** This issue has been marked as a duplicate of issue 6178 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 22 2013