Opened 11 years ago

Closed 11 years ago

#5731 closed Bugs (fixed)

Failure in boost/numeric/conversion when compiled without exceptions

Reported by: pmachata@… Owned by: Douglas Gregor
Milestone: To Be Determined Component: numeric
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc: antoshkka@…

Description

When build with gcc -fno-exceptions, the compilation fails on the following oneliner:

#include <boost/numeric/conversion/converter.hpp>

That's because naked "throw" is used in that code. I believe it should use boost::throw_exception instead. I'm attaching a patch that implements this change.

Attachments (1)

boost-1.47.0-exceptions.patch (897 bytes ) - added by pmachata@… 11 years ago.
Proposed fix

Download all attachments as: .zip

Change History (7)

by pmachata@…, 11 years ago

Proposed fix

comment:1 by pmachata@…, 11 years ago

Component: Nonenumeric
Owner: set to Douglas Gregor

comment:2 by anonymous, 11 years ago

can somebody review this patch? the issue with kdeedu-rocs is still valid with 1.48

comment:3 by Robert Ramey, 11 years ago

I looked at this and I don't like it.

I drags in a bunch of boost.exception stuff we're not using. This problem came up when BOOST_THROW_EXCEPTION was redefined by the authors of Boost Exception and surprised a lot of us with bloat code and other problems.

Think about this some more.

Robert Ramey

comment:4 by Petr Machata <pmachata@…>, 11 years ago

An exception is being thrown in header file. There's an existing tool for that in boost, boost::throw_exception. Many other (boost) libraries do it like that (though admittedly not all). It's a correctness issue, too, that code is invalid when compiled with -fno-exceptions. I don't think boost should support every odd compiler flag out there, but it seems that support for this one is well established.

in reply to:  3 comment:5 by Antony Polukhin, 11 years ago

Cc: antoshkka@… added
Version: Boost 1.47.0Boost 1.50.0

Replying to ramey:

I looked at this and I don't like it.

I drags in a bunch of boost.exception stuff we're not using. This problem came up when BOOST_THROW_EXCEPTION was redefined by the authors of Boost Exception and surprised a lot of us with bloat code and other problems.

There is a patch for BOOST_THROW_EXCEPTION that reduces code bloat #6450
Support for noexception build is really required, because such builds are widely used on embedded platforms and are part of C++ corporate style in some organizations.

I would advise to use BOOST_THROW_EXCEPTION instead of boost::throw_exception, because it gives better control to user, better debugging abilities and is meant to be used in all libraries.

This is a very popular bug and a lot of users want it fixed! It is duplicated in tickets #5076, #5393, #5800.

Please, fix it till 1.50 release or allow me to fix it (it is a trivial bug).

comment:6 by Antony Polukhin, 11 years ago

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.