
----- Original Message ----- From: "Andrey Semashev" <andrey.semashev@gmail.com> To: <boost@lists.boost.org> Sent: Saturday, September 06, 2008 8:59 AM Subject: Re: [boost] [exception] Incompatibility betweenboost::throwexception and throw prototype declarations
On Sat, Sep 6, 2008 at 9:16 AM, vicente.botet <vicente.botet@wanadoo.fr>wrote:
----- Original Message ----- From: "Emil Dotchevski" < emil@revergestudios.com> To: <boost@lists.boost.org> Sent: Saturday, September 06, 2008 6:52 AM Subject: Re: [boost] [exception] Incompatibility between boost::throwexception and throw prototype declarations
If G throws the excp using the boost::throw(excep) on 1.15 I was able to write
void F() thows (excp) { // ... G(); // ... }
With 1.136 this code do not compile any more because boost::throw_exception throws an unspecified exception. So what can I write instead of --unspecified--
void F() thows (excp, --unspecified--) { // ... G(); // ... }
I hope this answer your question, let me know if it is not the case.
If I'm not mistaken, you are safe to add base classes to the exception specification list. Since the "unspecified" exception derives from the "excep" (otherwise you wouldn't be able to catch it), I assume you don't need to change your code.
I have tried with a simple example that confirm what you said. #include <boost/throw_exception.hpp> #include <iostream> struct excp : std::exception {}; void G() { boost::throw_exception(excp()); } void F() throw (excp) { try { G(); } catch (excp& e) { std::cout << __LINE__ << std::endl; throw; } catch (...) { std::cout << __LINE__ << std::endl; throw; } } int main() { try { F(); } catch (excp& e) { std::cout << __LINE__ << std::endl; } return 0; } and compiled it with both versions. Everything is OK. Sorry for the noice, Vicente