[Issue 5021] New: Associative array assigned to in spite of exception
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 9 00:49:51 PDT 2010
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 at puremagic.com
ReportedBy: jmdavisProg at gmx.com
--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 2010-10-09 00:49:21 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 at 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: -------
More information about the Digitalmars-d-bugs
mailing list