Opened 9 years ago

Closed 9 years ago

#9215 closed Bugs (fixed)

Infinite loop when `any` constructor called for `const any&&`

Reported by: Antony Polukhin Owned by: Antony Polukhin
Milestone: Boost 1.55.0 Component: any
Version: Boost 1.54.0 Severity: Regression
Keywords: any const rvalue Cc:

Description

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)))
        {
        }

Test case:

#include <boost/any.hpp>
#include <string>

const boost::any getBoolVal()
{
    return false;
}

int main()
{
    boost::any vals[] = {1.0, std::string("1m"), getBoolVal()};
}

Thanks to Bo Peng for finding this issue!

Change History (3)

comment:1 by Antony Polukhin, 9 years ago

Owner: changed from nasonov to Antony Polukhin
Status: newassigned

comment:2 by Antony Polukhin, 9 years ago

(In [86213]) Fix for construction of any from const any&& (refs #9215)

comment:3 by Antony Polukhin, 9 years ago

Resolution: fixed
Status: assignedclosed

(In [86298]) Merge from trunk:

  • Fixed construction of any from const any&& (fixes #9215)
Note: See TracTickets for help on using tickets.