Ticket #9215 (closed Bugs: fixed)

Opened 2 years ago

Last modified 2 years ago

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!


Change History

comment:1 Changed 2 years ago by apolukhin

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

comment:2 Changed 2 years ago by apolukhin

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

comment:3 Changed 2 years ago by apolukhin

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

(In [86298]) Merge from trunk:

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

Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
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.