Hi I'm encountering a weird problem, when I try to use -fno-weak as one of the compiler options. The problem which I'm encountering will be clearer from the test- program below:
$ cat circle.h // circle.h class Circle{ int radius; public: Circle(int x):radius(x){}; }; $ cat throw.cpp #include "circle.h" using namespace std; void throwException() { throw(Circle(10)); } $ cat main.cpp #include "circle.h" #include<iostream> using namespace std; void throwException(); int main(int argc) { try{ throwException(); } catch(Circle x) { cout<<"caught circle"<<endl; } } When I don't use -fno-weak, program works fine as expected. $ g++ -c main.cpp; g++ -c throw.cpp;g++ -o test throw.o main.o $ ./test caught circle But when I use -fno-weak, the exception0handling fails: $ g++ -c -fno-weak main.cpp; g++ -c -fno-weak throw.cpp;g++ -o test throw.o main.o $ ./test terminate called after throwing an instance of 'Circle' Aborted The preliminary examination of the problem suggests that the problem is with the typeinfo data that C++ exception-handling uses. For case 1: $ nm -C test |grep typeinfo 08048c3c V typeinfo for Circle 08048c44 V typeinfo name for Circle For case 2: $ nm -C test |grep typeinfo 08048c3c r typeinfo for Circle 08048c5c r typeinfo for Circle 08048c44 r typeinfo name for Circle 08048c64 r typeinfo name for Circle It appears that since two different entries are being maintained for same type, the try-catch mechanism fails to identify the thrown type. gcc version being used is 4.2.0; but I've also reproduced this with gcc version 3.3.3 I surely do need to use -fno-weak. Also it won't be possible for me to move throwException() to main.cpp. Is there any way out here?? Regards Amit _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus