Hi, I would like to use boost with BOOST_NO_EXCEPTIONS [1] and the g++ -fno-exceptions flag. However, it appears that some spots in boost library code: a) throw exceptions with the "raw" throw keyword [instead of BOOST_THROW_EXCEPTION or boost::throw_exception] b) use try ... catch blocks without "#ifnef BOOST_NO_EXCEPTIONS" guards This leaves me with the following questions. 1) Is BOOST_NO_EXCEPTIONS actively supported or a legacy construct? 2) What is the "recommended" way to throw exceptions inside boost library code (BOOST_THROW_EXCEPTION, boost::throw_exception, etc)? 3) If this is not intended behavior, would incremental patches to remove these dependencies be considered for inclusion? Thanks, Andy [1] http://www.boost.org/doc/libs/1_46_1/libs/exception/doc/throw_exception.html
On Mon, Mar 21, 2011 at 4:13 PM, Hochhaus, Andrew
Hi,
I would like to use boost with BOOST_NO_EXCEPTIONS [1] and the g++ -fno-exceptions flag. However, it appears that some spots in boost library code:
a) throw exceptions with the "raw" throw keyword [instead of BOOST_THROW_EXCEPTION or boost::throw_exception] b) use try ... catch blocks without "#ifnef BOOST_NO_EXCEPTIONS" guards
This leaves me with the following questions.
1) Is BOOST_NO_EXCEPTIONS actively supported or a legacy construct?
It is actively supported.
2) What is the "recommended" way to throw exceptions inside boost library code (BOOST_THROW_EXCEPTION, boost::throw_exception, etc)?
For BOOST_NO_EXCEPTIONS to work, it is sufficient to use boost::throw_exception to throw. However, it is recommended to use BOOST_THROW_EXCEPTION instead, which has the benefit of storing the file and line number into the exception object. See http://www.boost.org/doc/libs/release/libs/exception/doc/BOOST_THROW_EXCEPTI....
3) If this is not intended behavior, would incremental patches to remove these dependencies be considered for inclusion?
You mean dependencies on boost/throw_exception.hpp? I'd think that patches that convert naked throws to BOOST_THROW_EXCEPTION should be accepted, since the boost/throw_exception.hpp header is extremely lightweight. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
Thanks Emil.
On Mon, Mar 21, 2011 at 7:01 PM, Emil Dotchevski
2) What is the "recommended" way to throw exceptions inside boost library code (BOOST_THROW_EXCEPTION, boost::throw_exception, etc)?
For BOOST_NO_EXCEPTIONS to work, it is sufficient to use boost::throw_exception to throw. However, it is recommended to use BOOST_THROW_EXCEPTION instead, which has the benefit of storing the file and line number into the exception object. See http://www.boost.org/doc/libs/release/libs/exception/doc/BOOST_THROW_EXCEPTI....
That is what I was hoping for.
3) If this is not intended behavior, would incremental patches to remove these dependencies be considered for inclusion?
You mean dependencies on boost/throw_exception.hpp? I'd think that patches that convert naked throws to BOOST_THROW_EXCEPTION should be accepted, since the boost/throw_exception.hpp header is extremely lightweight.
Yes. I'm hoping to convert naked throws to BOOST_THROW_EXCEPTION. While I'm at it, any reason why naked {try,catch} shouldn't also be converted to BOOST_{TRY,CATCH,CATCH_END}? boost/detail/no_exceptions_support.hpp -Andy
On Wed, Mar 30, 2011 at 3:16 PM, Hochhaus, Andrew
Thanks Emil.
On Mon, Mar 21, 2011 at 7:01 PM, Emil Dotchevski
wrote: 2) What is the "recommended" way to throw exceptions inside boost library code (BOOST_THROW_EXCEPTION, boost::throw_exception, etc)?
For BOOST_NO_EXCEPTIONS to work, it is sufficient to use boost::throw_exception to throw. However, it is recommended to use BOOST_THROW_EXCEPTION instead, which has the benefit of storing the file and line number into the exception object. See http://www.boost.org/doc/libs/release/libs/exception/doc/BOOST_THROW_EXCEPTI....
That is what I was hoping for.
3) If this is not intended behavior, would incremental patches to remove these dependencies be considered for inclusion?
You mean dependencies on boost/throw_exception.hpp? I'd think that patches that convert naked throws to BOOST_THROW_EXCEPTION should be accepted, since the boost/throw_exception.hpp header is extremely lightweight.
Yes. I'm hoping to convert naked throws to BOOST_THROW_EXCEPTION.
While I'm at it, any reason why naked {try,catch} shouldn't also be converted to BOOST_{TRY,CATCH,CATCH_END}?
Yes. See the long discussion we had about that issue. :) My personal opinion is that all throws in Boost should use BOOST_THROW_EXCEPTION, because otherwise we're taking away functionality that might be critical for some users of a library. Beyond that, I don't think we should be converting try...catch uses blindly. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
Message du 31/03/11 00:42 De : "Emil Dotchevski" A : "Hochhaus, Andrew" Copie à : boost-users@lists.boost.org Objet : Re: [Boost-users] no exceptions
On Wed, Mar 30, 2011 at 3:16 PM, Hochhaus, Andrew wrote:
Thanks Emil.
On Mon, Mar 21, 2011 at 7:01 PM, Emil Dotchevski wrote:
2) What is the "recommended" way to throw exceptions inside boost library code (BOOST_THROW_EXCEPTION, boost::throw_exception, etc)?
For BOOST_NO_EXCEPTIONS to work, it is sufficient to use boost::throw_exception to throw. However, it is recommended to use BOOST_THROW_EXCEPTION instead, which has the benefit of storing the file and line number into the exception object. See http://www.boost.org/doc/libs/release/libs/exception/doc/BOOST_THROW_EXCEPTI....
That is what I was hoping for.
Unfortunately there is no recommended way to work without no exceptions, as the long thread Emil mentioned explains. At least it is not included in the guidelines.
3) If this is not intended behavior, would incremental patches to remove these dependencies be considered for inclusion?
You mean dependencies on boost/throw_exception.hpp? I'd think that patches that convert naked throws to BOOST_THROW_EXCEPTION should be accepted, since the boost/throw_exception.hpp header is extremely lightweight.
Yes. I'm hoping to convert naked throws to BOOST_THROW_EXCEPTION.
I'm sure that most of the library authors will accept the patch, but I will request directly before doing it.
While I'm at it, any reason why naked {try,catch} shouldn't also be converted to BOOST_{TRY,CATCH,CATCH_END}?
There is alreadt boost/detail/no_exceptions_support.hpp void foo() { BOOST_TRY { ... } BOOST_CATCH(const std::bad_alloc&) { ... BOOST_RETHROW } BOOST_CATCH(const std::exception& e) { ... } BOOST_CATCH_END } With exception support enabled it will expand into: void foo() { { try { ... } catch (const std::bad_alloc&) { ... throw; } catch (const std::exception& e) { ... } } } With exception support disabled it will expand into: void foo() { { if(true) { ... } else if (false) { ... } else if (false) { ... } } }
Yes. See the long discussion we had about that issue. :)
See the dev ML.
Thanks for the guidance Emil and Vicente.
On Wed, Mar 30, 2011 at 5:59 PM, Vicente BOTET
While I'm at it, any reason why naked {try,catch} shouldn't also be converted to BOOST_{TRY,CATCH,CATCH_END}?
There is alreadt boost/detail/no_exceptions_support.hpp
Yes, these are the macros I was referring to.
Yes. See the long discussion we had about that issue. :)
See the dev ML.
Will do. I believe this is the thread you are referencing: http://lists.boost.org/Archives/boost/2011/03/178982.php -Andy
participants (3)
-
Emil Dotchevski
-
Hochhaus, Andrew
-
Vicente BOTET