Modify

Opened 4 years ago

Closed 4 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!

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by Antony Polukhin

Owner: changed from nasonov to Antony Polukhin
Status: newassigned

comment:2 Changed 4 years ago by Antony Polukhin

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

comment:3 Changed 4 years ago by Antony Polukhin

Resolution: fixed
Status: assignedclosed

(In [86298]) Merge from trunk:

  • Fixed construction of any from const any&& (fixes #9215)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Antony Polukhin.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.