Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5800 closed Bugs (fixed)

lexical_cast doesn't compile without exceptions

Reported by: Mathias Gaunard Owned by: Antony Polukhin
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.

Change History (7)

comment:1 by Mathias Gaunard, 11 years ago

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 by Antony Polukhin, 11 years ago

Component: lexical_castnumeric
Milestone: To Be DeterminedBoost 1.48.0
Owner: changed from nasonov to Douglas Gregor
Version: Boost Development TrunkBoost 1.47.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 by Antony Polukhin, 11 years ago

Cc: antoshkka@… added

comment:4 by Antony Polukhin, 11 years ago

Cc: antoshkka@… removed
Component: numericlexical_cast
Milestone: Boost 1.48.0Boost 1.50.0
Owner: changed from Douglas Gregor to Antony Polukhin
Status: newassigned

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

comment:5 by Antony Polukhin, 11 years ago

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 by Antony Polukhin, 11 years ago

Resolution: fixed
Status: assignedclosed

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

comment:7 by Antony Polukhin, 11 years ago

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

Note: See TracTickets for help on using tickets.