digitalmars.D.bugs - [Issue 10972] New: aggregate postblit doesn't clean up in case of failure
- d-bugmail puremagic.com (78/78) Sep 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10972
http://d.puremagic.com/issues/show_bug.cgi?id=10972 Summary: aggregate postblit doesn't clean up in case of failure Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: monarchdodra gmail.com Structs will not recursively destroy their members if the construction scheme fails: import std.stdio; struct A { this(this) {writeln("copied A");} ~this() {writeln("destroy A");} } struct B { this(this) { writeln("B says what?"); throw new Exception("BOOM!"); } ~this() {writeln("destroy B");} } struct S { A a; B b; } void main() { S s1; S s2; writeln("----"); try s2 = s1; catch {} writeln("----"); try S s3 = s1; catch {} writeln("----"); } ---- copied A B says what? ---- copied A B says what? ---- destroy B destroy A destroy B destroy A Be it CC, or "postblit-based" assignment, first, the "A" element is constructed, the B fails to CC, but the first A is never actually destroyed. Postblit should first destroy all created members before propagating the exception. This should be pretty standard and expected behavior for struct construction. The irony is that only static arrays handle this correctly, but only because they have their own (arguably weird) construction scheme. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 05 2013