Opened 7 years ago
Closed 6 years ago
#11461 closed Feature Requests (fixed)
signals2/signal.hpp does not compile with exceptions off
Reported by: | Owned by: | Frank Mori Hess | |
---|---|---|---|
Milestone: | To Be Determined | Component: | signals2 |
Version: | Boost 1.58.0 | Severity: | Problem |
Keywords: | Cc: | gromer@… |
Description
boost/signals2/signal.hpp includes boost/signals2/detail/slot_call_iterator.hpp
which uses throw (instead of boost::throw_exception as it should)
with exceptions off, you cannot use throw(), try, catch, etc., hence BOOST_TRY, BOOST_CATCH, BOOST_RETHROW
Attachments (1)
Change History (10)
by , 7 years ago
Attachment: | slot_call_iterator_throw_bug.diff added |
---|
comment:1 by , 7 years ago
Type: | Bugs → Feature Requests |
---|
comment:2 by , 7 years ago
I don't see how this can break automatic slot disconnection. The presumption is that boost::throw_exception
either throws an exception (no change from the current code) or terminates the program (which makes slot disconnection a moot point).
Many large codebases are built without exceptions; whether or not Boost is required to support them, it's a major deficiency for it not to. Why not just take the fix, when it's so trivial?
comment:3 by , 7 years ago
Cc: | added |
---|
comment:4 by , 7 years ago
Perhaps I should have said "break the program when it tries to use automatic slot disconnection"? Signals2 causing the program to terminate when the signals2 is used as it is documented to be used is about as broken as broken gets.
comment:5 by , 7 years ago
Oh, I see what you're saying: Signals2 relies on this exception for non-exceptional control flow. That being the case, yes, Signals2 shouldn't compile with exceptions disabled, but that means we have the opposite problem: it doesn't fail to compile reliably enough. It looks like Clang will compile this code just fine with exceptions disabled, and although it doesn't compile in gcc, I would argue that's a bug. The line of code at issue is a re-throw inside a catch
block, so it's harmless when exceptions are disabled, because it will never be reached.
In any event, this is the wrong place for the error to occur: the code that makes Signals2 unsafe with exceptions disabled is the code that "swallows" exceptions: the catch
blocks that don't re-throw in last_value.hpp
and optional_last_value.hpp
. Those whole functions (or the whole files, like boost/thread/future.hpp
) should be wrapped in #ifndef BOOST_NO_EXCEPTIONS
.
follow-up: 8 comment:7 by , 7 years ago
Why does Signals2 use boost::throw_exception()
where the exception is originally thrown? boost::throw_exception()
is tantamount to abort()
when exceptions are disabled, so it seems like it shouldn't be used for conditions that are expected to occur in normal use.
comment:8 by , 7 years ago
Replying to gromer@…:
Why does Signals2 use
boost::throw_exception()
where the exception is originally thrown?
I've removed all usage of boost::throw_exception from develop.
comment:9 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
signals2 should be mostly usable now without exceptions, the changes will be in 1.62.
The proposed change may make it compile, but IIRC it will break automatic slot disconnection when compiling without exceptions. Boost libraries are not required to work without exception support. I'm leaving this ticket open as a feature request, but I have no immediate plans to resolve it.