gcc-3.0 bug - destructor not called when throwing an exception
Ryszard Kabatek
Ryszard.Kabatek@softax.pl
Fri Jul 27 05:43:00 GMT 2001
Hi,
I saw the message below on a mailing list, perhaps it was reported to gcc-bugs.
I can reproduce the bug on linux (RedHat 7.0) with gcc-3.0.
It seems to be a serious problem.
Regards
--
Ryszard Kabatek
=========================================
The symptom is that omniNames hangs when one runs eg3_impl 1 or 2 times.
This is caused by a bug in the code generated by gcc 3.0. A simple test
case
is:
----------------------------------
#include <iostream.h>
class A {
public:
A() {
cerr << "A()" << endl;
}
~A() {
cerr << "~A()" << endl;
}
};
void f() {
A a;
try {
throw long(0);
}
catch(int&) {
cerr << "Got int exception" << endl;
}
}
int
main(int,char**) {
try {
f();
}
catch(long& v) {
cerr << "Got long " << v << endl;
}
return 0;
}
-------------
Compile the test code with gcc-3.0 on linux. Execute the program will
produce the following
output:
$ ./testcc
A()
Got long 0
The correct output is:
$ ./testcc
A()
~A()
Got long 0
The missing dtor call is fatal as this means that any resource
allocation
will not be released.
This leads to various deadlock within the ORB.
In summary, don't bother using gcc 3.0 until the bugs are fixed.
Regards,
Sai-Lai
More information about the Gcc-bugs
mailing list