g++: Exception handling in constructor
Gokhan Kisacikoglu
kisa@centropolisfx.com
Tue Dec 10 16:24:00 GMT 2002
This is not throwing that exception, it seems like a bug in the g++
parser;
#include <iostream>
using std::cout;
using std::cerr;
using std::endl;
struct Exception { };
class Bad {
public:
Bad() {}
Bad(int) { cout<<"Throwing Exception..."<<endl; throw Exception(); }
};
class Test {
Bad b;
public:
Test()
{
try
{
b = Bad(0);
cout<<"Test"<<endl;
}
catch(Exception)
{
cerr<<"Caught Exception -- this is right"<<endl;
}
}
};
int main()
{
try {
Test t;
} catch(Exception) {
cerr<<"Caught Exception -- should not happen"<<endl;
}
}
More information about the Gcc-help
mailing list