|
Boost : |
Subject: Re: [boost] [any] Infinite loop in boost::any in boost release 1.54.0 using Visual C++ 2010
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2013-10-09 07:38:33
2013/10/8 Bo Peng <elapsing_at_[hidden]>
> This very simple code:
>
> #include <boost/any.hpp>
> #include <string>
>
> const boost::any getBoolVal()
> {
> return false;
> }
>
> int main()
> {
> boost::any vals[] = {1.0, std::string("1m"), getBoolVal()};
> }
>
> When built using Visual C++ 2010, it will run into a infinite loop:
>
<...>
Thanks for finding that issue. I'll take care of it.
Code at line 70 in boost/any.hpp must look like this:
template<typename ValueType>
any(ValueType&& value
, typename boost::disable_if<boost::is_same<any&, ValueType>
>::type* = 0 // disable if value has type `any&`
, typename boost::disable_if<boost::is_const<ValueType>
>::type* = 0) // disable if value has type `const ValueType&&`
: content(new holder< typename remove_reference<ValueType>::type
>(static_cast<ValueType&&>(value)))
{
}
Otherwise there'll be infinite loop with `any(const any&&)` and
`any::holder(const ValueType&)`, that calls for copy constructor of
ValueType.
Created a ticket for that bug: https://svn.boost.org/trac/boost/ticket/9215
-- Best regards, Antony Polukhin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk