This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: g++: Exception handling in constructor
- From: Gokhan Kisacikoglu <kisa at centropolisfx dot com>
- To: Frank Grimm <fgr at foobar-cpa dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 10 Dec 2002 16:25:27 -0800
- Subject: Re: g++: Exception handling in constructor
- Organization: Centropolis Effects, LLC
- References: <20021210112353.GX1117@zlug.org>
- Reply-to: kisa at centropolisfx dot com
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;
}
}