Checking exception specifications
Sebastian Ritterbusch
uabp@rz.uni-karlsruhe.de
Wed Aug 12 02:58:00 GMT 1998
According to Ross Smith:
> I agree. Consider this sort of thing:
> ...
Like this? (In a different context)
#include <iostream>
class complex
{
private: double re,im;
friend double & Real(complex &a) { return a.re; }
friend double & Imag(complex &a) { return a.im; }
};
std::ostream & operator <<(std::ostream &o,const complex &a)
{ // Or another "User"-written function
return o << Real(a) << '+' << Imag(a) << 'i';
// If the compiler isn't _very_ smart ;), this will result
// in a warning although a isn't changed.
}
Okay, there are several ways to get around this but in my opinion is warning
about "const" the same thing as warning about possibly unhandled exceptions.
If you are serious about exceptions you will agree.
The problem is that if there is any unhandled exception and it occurs then
the program terminates. (And up to now there is _no_ way preventing this.)
But currently other things are more important than this, although
implementing this warning probably wouldn't be too difficult, but correcting
the header-files that use exception specifications.. ;)
I will try to find a way to check them on my own until it will be
implemented. I knew i was too early... ;)
Ciao, Sebastian.
More information about the Gcc
mailing list