G
Guest
When language changes make old code uncompilable, that's not what is
called protection of investment.
New compilers (g++ > 3.2.3) reject classes where methods throw the
class they belong to.
gcc 2.95.3 allowed it.
What are the minimal modification, that leave the usage of the class
sound and can be compiled by newer compilers.
Thank you
( compile the following code with s.th. like g++ -g -o Exception
Exception.cpp -lstlport_gcc )
#include "iostream"
class Exception {
public:
Exception(int);
void setErrNo(int i) throw(Exception);
int errNo;
};
Exception::Exception(int e) {
errNo=e;
}
void Exception::setErrNo(int i) throw(Exception) {
auto Exception methodException(2);
errNo=i;
throw(methodException);
};
int main(char argc, char *argv[], char *env[]) {
try {
auto Exception mainException(1);
mainException.setErrNo(42);
} catch (Exception caughtmainException) {
std::cout << "caught mainException:" << mainException.errNo <<
std::endl;
}
}
called protection of investment.
New compilers (g++ > 3.2.3) reject classes where methods throw the
class they belong to.
gcc 2.95.3 allowed it.
What are the minimal modification, that leave the usage of the class
sound and can be compiled by newer compilers.
Thank you
( compile the following code with s.th. like g++ -g -o Exception
Exception.cpp -lstlport_gcc )
#include "iostream"
class Exception {
public:
Exception(int);
void setErrNo(int i) throw(Exception);
int errNo;
};
Exception::Exception(int e) {
errNo=e;
}
void Exception::setErrNo(int i) throw(Exception) {
auto Exception methodException(2);
errNo=i;
throw(methodException);
};
int main(char argc, char *argv[], char *env[]) {
try {
auto Exception mainException(1);
mainException.setErrNo(42);
} catch (Exception caughtmainException) {
std::cout << "caught mainException:" << mainException.errNo <<
std::endl;
}
}