Possible Duplicate:
Can objects with private copy constructors be thrown?
As I know, when you trow object as value, copy should be created. So copy constructor should be called if exist. If copy ctor exists and is private then this should cause compilation error. Here is code sample
class Exception {
public:
Exception() {
cout << "Exception()" << endl;
}
~Exception() {
cout << "~Exception() " << endl;
}
private:
Exception(const Exception &c) {
cout << "Exception(c)" << endl;
}
};
And next code should lead to compilation error.
try {
Exception local;
throw local;
} catch (...) {
}
But both in VS 2005 and VS 2008 succesfully compile that code and call private ctor. Am I wrong that this is non standard behaviour and is an error in compiler?