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 , 9 years ago
| Owner: | changed from to | 
|---|---|
| Status: | new → assigned | 
comment:2 by , 9 years ago
comment:3 by , 9 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | assigned → closed | 
  Note:
 See   TracTickets
 for help on using tickets.
    

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