Re: Destructor call of virtual base class - what happens with exception spec?
"Kai-Uwe Bux" <jkherciueh@gmx.net>
Does it matter when there is so wide consensus that dtors shall not
throw?
Note that none of the constructors above throws. One of them just has a
throw specification that "reserves the right" to throw. The constructor as
shown, however, does not.
I don't know whether there is a consensus about throw-specifications of
constructors.
I was talking about destructors, not constructors. ctors are the best
candidates to throw, as other options to signal a problem are limited or
problematic.
While exceptions escaping dtors can wreak much havoc so many many template
libraries, including STL just call it UB if the subject does so.
Handling the consequences is problematic too -- and the most evil thing is
that call of other destructors gets prevented, killing the ctor/dtor
symmetry most good design builds on in a C++ program.
And almost that wide to not write exceptions specs?
Sure it matters. Since two compilers disagree on whether the code is well-
formed, we want to know _where_ to file a bug report :-)
LOL. Certainly I agree that the standard's verdict is better be clear, and
implementations do it corectly. :) Just IIRC exception spec is already
deprecated in c++0x -- and some widely used implementations deliberately
make it for different semantics.
Who would allow those fragments into any real program? I'd definitely
not.
Well, his trickery about throw specifications (once thoroughly understood)
is about making the compiler barf at certain inputs and thereby forcing
the
client of some library to code in a certain way. Such techniques, per se,
might prove useful in some circumstances; and I cannot rule out that the
"throw-spec-trick" could become part of such a technique.
Ah, I didn't think about such use. But it seems practice makes its
usability too limited for real practice.