www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - exception not caught

reply Nick <Nick_member pathlink.com> writes:
Stumbled over the following bug:

# import std.stdio;
# int bb[char[]];
# void main()
# {
#   foreach(char[] s, int i; bb)
#     writef(); // This never gets called, but the bug goes away if it
#               // is exchanged with eg. {}
#
#   bb["a"] = 1;
#
#   foreach(int b; bb)
#     try throw new Error("foo");
#     catch(Error e)
#       // BUG: The exception isn't caught
#       {writefln("Caught error ", e);}
# }

Exchanging the writef() with {} or another simple function call removes the bug.
Removing the "char[] s" loop variable or any of the foreach statements also does
the trick.

Nick (using 0.127 on linux)
Jun 21 2005
parent Thomas Kuehne <thomas-dloop kuehne.this-is-spam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nick schrieb am Tue, 21 Jun 2005 17:22:42 +0000 (UTC):
 Stumbled over the following bug:

 # import std.stdio;
 # int bb[char[]];
 # void main()
 # {
 #   foreach(char[] s, int i; bb)
 #     writef(); // This never gets called, but the bug goes away if it
 #               // is exchanged with eg. {}
 #
 #   bb["a"] = 1;
 #
 #   foreach(int b; bb)
 #     try throw new Error("foo");
 #     catch(Error e)
 #       // BUG: The exception isn't caught
 #       {writefln("Caught error ", e);}
 # }

 Exchanging the writef() with {} or another simple function call removes the
bug.
 Removing the "char[] s" loop variable or any of the foreach statements also
does
 the trick.

 Nick (using 0.127 on linux)
Added to DStress as http://dstress.kuehne.cn/run/c/catch_05_A.d http://dstress.kuehne.cn/run/c/catch_05_B.d http://dstress.kuehne.cn/run/c/catch_05_C.d http://dstress.kuehne.cn/run/c/catch_05_E.d http://dstress.kuehne.cn/run/c/catch_05_F.d http://dstress.kuehne.cn/run/c/catch_05_G.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCuaHh3w+/yD4P9tIRAkMcAJ40m1F9rekzJ3aqXeLd260HrOjKcgCeLGSe zJK71T2mNTohssHHgqTWi8g= =8565 -----END PGP SIGNATURE-----
Jun 22 2005