digitalmars.D.bugs - [Issue 5021] New: Associative array assigned to in spite of exception
- d-bugmail puremagic.com (51/51) Oct 09 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5021
- d-bugmail puremagic.com (18/18) Aug 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5021
- d-bugmail puremagic.com (13/13) Feb 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5021
http://d.puremagic.com/issues/show_bug.cgi?id=5021 Summary: Associative array assigned to in spite of exception Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: jmdavisProg gmx.com PDT --- This program: import std.string; int func() { throw new Exception("It's an exception."); } void main() { int[string] arr; try { arr["hello"] = func(); } catch(Exception e) { } assert(arr.length == 0, format("actual: %s", arr.length)); } results in this output: core.exception.AssertError d.d(20): actual: 1 ---------------- ./d(_d_assert_msg+0x18) [0x8081ab8] ./d(_Dmain+0x8f) [0x807eb0f] ./d(extern (C) int rt.dmain2.main(int, char**)) [0x8081ca6] ./d(extern (C) int rt.dmain2.main(int, char**)) [0x8081c00] ./d(extern (C) int rt.dmain2.main(int, char**)) [0x8081cea] ./d(extern (C) int rt.dmain2.main(int, char**)) [0x8081c00] ./d(main+0x96) [0x8081ba6] /usr/lib32/libc.so.6(__libc_start_main+0xe6) [0xf75f1c76] ./d() [0x807e9a1] The associative array should have been unchanged. The assignment never took place because an exception was thrown before the function could return the value to be assigned to the associative array. Since no assignment took place, the associative array should not have changed, but it did. It has 1 value in it where it should have 0. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 09 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5021 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |major PDT --- Okay. I just spent a few hours trying to track down a failure due to this, so I'm bumping it up to major (what the exact criteria for what level a bug is, I don't know, but this one is definitely annoying). What seems to be happening here is that the associative array gets assigned a default-initialized value if an exception was thrown from the expression on the right-hand side of the assignment. My best guess is that a default-initialized element is added to the AA as part of arr["hello"], and then when the assignment doesn't happen due to the exception, the AA is left with the default-initialized value in it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 12 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5021 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |DUPLICATE Same cause, same fix. *** This issue has been marked as a duplicate of issue 3825 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 02 2012