Modify

Ticket #5800 (closed Bugs: fixed)

Opened 3 years ago

Last modified 2 years ago

lexical_cast doesn't compile without exceptions

Reported by: mgaunard Owned by: apolukhin
Milestone: Boost 1.50.0 Component: lexical_cast
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

With GCC, simply including <boost/lexical_cast.hpp> is enough to yield the following error:

In file included from /media/data/dev/svn/boost-trunk/boost/numeric/conversion/converter.hpp:14:0,
                 from /media/data/dev/svn/boost-trunk/boost/numeric/conversion/cast.hpp:32,
                 from /media/data/dev/svn/boost-trunk/boost/lexical_cast.hpp:40,
test.cpp:14:
/media/data/dev/svn/boost-trunk/boost/numeric/conversion/converter_policies.hpp: In member function ‘void boost::numeric::def_overflow_handler::operator()(boost::numeric::range_check_result)’:
/media/data/dev/svn/boost-trunk/boost/numeric/conversion/converter_policies.hpp:162:31: error: exception handling disabled, use -fexceptions to enable

It would be nice if Boost.Lexical_cast (and Boost.Numeric Convert that it seems to use) could be made to work with exceptions disabled.

The reason I need this is because Boost.Math seems to depend on lexical_cast, and I want to use it without exception support.

Attachments

Change History

comment:1 Changed 3 years ago by mgaunard

The best solution would be to replace all references to "throw" by the macro BOOST_THROW_EXCEPTION which expands to the right thing depending on whether exceptions are enabled or not.

comment:2 Changed 3 years ago by apolukhin

  • Owner changed from nasonov to dgregor
  • Version changed from Boost Development Trunk to Boost 1.47.0
  • Component changed from lexical_cast to numeric
  • Milestone changed from To Be Determined to Boost 1.48.0

It is not a lexical_cast bug. Lexical cast uses throw_exception function, which works correct with BOOST_NO_EXCEPTIONS flag.

I`ll redirect this issue to numeric_cast library. If this bug wont be fixed soon. Ill fix it myself (it is a trivial bug)

comment:3 Changed 3 years ago by apolukhin

  • Cc antoshkka@… added

comment:4 Changed 2 years ago by apolukhin

  • Cc antoshkka@… removed
  • Owner changed from dgregor to apolukhin
  • Status changed from new to assigned
  • Component changed from numeric to lexical_cast
  • Milestone changed from Boost 1.48.0 to Boost 1.50.0

I`ll do some workaround to allow lexical_cast compile with exceptions off even if numeric cast requires exceptions.

comment:5 Changed 2 years ago by apolukhin

Updated in r77116 (added tests, some workarounds, updated documentation, enabled exception handling with -fvisibility=hidden flag)
Unable to make a good workaround, without copy-pasting a lot of numeric_cast code. Continue to wait for #5731, #5076, #5393 resolutions.

comment:6 Changed 2 years ago by apolukhin

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [77234]) Fixes #5731, fixes #5076, fixes #5393, fixes #5800 Now numeric_cast (and lexical_cast) can be compiled with disabled exceptions

comment:7 Changed 2 years ago by apolukhin

(In [77236]) More strict tests for disabled exceptions (for fixed #5800)

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.