Opened 4 years ago

Closed 4 years ago

#9215 closed Bugs (fixed)

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

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


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 apolukhin

  • Owner changed from nasonov to apolukhin
  • Status changed from new to assigned

comment:2 Changed 4 years ago by apolukhin

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

comment:3 Changed 4 years ago by apolukhin

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [86298]) Merge from trunk:

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

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain apolukhin.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.