|
Boost : |
From: Doug Gregor (dgregor_at_[hidden])
Date: 2005-10-12 13:43:36
Hi Andreas,
On Oct 12, 2005, at 10:57 AM, Andreas Pokorny wrote:
> We just stumbled across a small problem with Boost.Signals,
> while playing with the symbol visibility features of gcc-3.4 and
> gcc-4. That feature is still buggy, but it unveiled some strange
> code.
We've stumbled into this as well.
> The code is in signal_template.hpp:
>
> template<typename Pair>
> R operator()(const Pair& slot) const {
> F* target = const_cast<F*>(any_cast<F>(&slot.second));
> return (*target)(BOOST_SIGNALS_BOUND_ARGS);
> }
>
> I dont see why any_cast is used here at all. The type safety
> is guranteed by the interface of Boost.Signals, so I doubt that
> someone will be able to abuse the library. I believe the author
> of that code had the same in mind, since he did not test
> target != 0 before invoking the target. So in my opinion a
> simple reinterpret_cast should suffice here. It would also
> fix our issue, although that one is caused by gcc.
You're right. Our options are:
1) Fix any_cast to compare typeid().name() instead of type_info
objects
2) Make an unsafe_any_cast that doesn't do the check
3) Switch signals to use void*'s
For 1.33.1, I like #2 best because it affects the least amount of code.
For 1.34.0 and beyond, #1 is probably our best bet so that others don't
run into the same problem.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk