At the risk of wading in too deep... there is one aspect of exception
specification checking that I've become absolutely convinced would
benefit greatly from static checking:
A::~A() static throw(); // or whatever syntax
That is, there is some code that you know should not throw anything,
and it would be most helpful if one could get compiler help on that.
If it throws an exception, it really doesn't matter what it throws.
If it doesn't throw an exception, that is a crucial property to
writing code with known exception safety guarantees (basic, strong,
nothrow).
If I write something like a destructor, move constructor or copy
constructor with an empty throw spec, it isn't because I want
unexpected() to be called just in case some exception is called. It
is because I want to broadcast that this function can't fail. But
that's not what C++ says an empty throw spec means.
For some code, it is essential that it have a "no fail" property.
That includes C++ destructors and "finally clauses" in other
languages. Automated help in this department would be incredibly
valuable. Being alerted that code you thought was nothrow has
suddenly become throwing because of a remote change in some function
you're calling would greatly aid robustness (much like const
correctness does today). Otoh if some remote function changes from
throwing X to throwing Y, that's really not going to impact the
client's fundamental design (though it is an API-breaking change).
In a nutshell, if I write:
struct A
{
int data_;
int get_data() const static throw() {return data_;} // or
whatever syntax for throw()
};
I'd like a diagnostic if get_data() generates code to call
std::unexpected().
-Howard