Modify

Ticket #5191 (closed Bugs: fixed)

Opened 3 years ago

Last modified 3 years ago

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

Change History

comment:1 Changed 3 years ago by igaztanaga

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

Fixed in Boost 1.47

View

Add a comment

Modify Ticket

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