Modify

Opened 6 years ago

Closed 6 years ago

#5191 closed Bugs (fixed)

intrusive unordered_set: const version of iterator_to() won't compile

Reported by: paul.d.rose@… Owned by: igaztanaga
Milestone: To Be Determined Component: intrusive
Version: Boost 1.45.0 Severity: Problem
Keywords: Cc:

Description

Discovered on 1_38_0 using g++ 4.3.2 on SuSE Linux Reproduced on 1_45_0 using g++ 4.2.1 on Macintosh (XCode)

Reproduce by adding

   MyClass const &cr = values[0];
   base_set.iterator_to(cr);

to the bottom of the documentation example for unordered_set.

iterator_to is trying to construct a const_iterator from a const bucket iterator, but this isn't supported by the iterator constructor. That lack of support by the iterator constructor seems to be by design (the internal bucket iterator is a non-const slist iterator).

It appears that iterator_to is trying to call the non-cost priv_value_to_node by casting away the constness of the value param, but since the 'this' pointer is still const, the const version of priv_value_to_node is called instead.

Removing the const_cast of hte value param, and adding a const_cast to the return value of priv_value_to_node seems to fix things just fine in 1_38_0.

I tried changing:

  return const_iterator(bucket_type::s_iterator_to(
    priv_value_to_node(const_cast<reference>(value))), this);

to:

  return const_iterator(bucket_type::s_iterator_to(
    const_cast<node &>(priv_value_to_node(value))), this);

in iterator_to in file boost/intrusive/hashtable.hpp (near line 1682 in 1_38_0) and it seems to be working just fine.

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by igaztanaga

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

Fixed in Boost 1.47

Add Comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.