[Issue 315] Exception handling is broken for delegates on Linux
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Sep 3 08:10:14 PDT 2006
http://d.puremagic.com/issues/show_bug.cgi?id=315
juanjo at comellas.com.ar changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |juanjo at comellas.com.ar
------- Comment #1 from juanjo at comellas.com.ar 2006-09-03 10:10 -------
I'm attaching a copy of the original bug report to make it easy for people
checking this bug:
As of version 0.150, the offsets of the code within a delegate's function
handler are not correctly calculated. All of them seem to be set relative to
the address of the first delegate declared within the scope. This results in
the following code breaking. The windows version does not have this problem.
#class Tester
#{
# this(void delegate() dg_) { dg = dg_; }
# void delegate() dg;
# void stuff() { dg(); }
#}
#
#unittest
#{
# writefln("Starting test");
#
# int a = 0;
# int b = 0;
# int c = 0;
# int d = 0;
#
# try
# {
# a++;
# throw new Exception("test1");
# a++;
# }
# catch(Exception e)
# {
# e.print;
# b++;
# }
# finally
# {
# c++;
# }
#
# writefln("initial test.");
#
# assert(a == 1);
# assert(b == 1);
# assert(c == 1);
#
# writefln("pass");
#
# Tester t = new Tester(
# delegate void()
# {
# try
# {
# a++;
# throw new Exception("test2");
# a++;
# }
# catch(Exception e)
# {
# b++;
# throw e;
# b++;
# }
# });
#
# try
# {
# c++;
# t.stuff();
# c++;
# }
# catch(Exception e)
# {
# d++;
# e.print;
# }
#
# assert(a == 2);
# assert(b == 2);
# assert(c == 2);
# assert(d == 1);
#
#
# int q0 = 0;
# int q1 = 0;
# int q2 = 0;
# int q3 = 0;
#
# Tester t2 = new Tester(
# delegate void()
# {
# try
# {
# q0++;
# throw new Exception("test3");
# q0++;
# }
# catch(Exception e)
# {
# writefln("Never called.");
# q1++;
# throw e;
# q1++;
# }
# });
#
# try
# {
# q2++;
# t2.stuff();
# q2++;
# }
# catch(Exception e)
# {
# q3++;
# e.print();
# }
#
# assert(q0 == 1);
# assert(q1 == 1);
# assert(q2 == 1);
# assert(q3 == 1);
#
# writefln("Passed!");
#}
The catch block in the second delegate never gets invoked. On a Linux
machine.
My output is as follows:
Starting test
test1
initial test.
pass
test2
test3
Error: AssertError Failure test(117)
While on windows, it passes with:
Starting test
test1
initial test.
pass
test2
Never called.
test3
Passed!
-Mik
--
More information about the Digitalmars-d-bugs
mailing list