Opened 9 years ago

Closed 8 years ago

#9650 closed Bugs (fixed)

intrusive list with stateful value traits

Reported by: Matei David <matei@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: intrusive
Version: Boost 1.55.0 Severity: Problem
Keywords: intrusive list iterator_to with stateful traits Cc:

Description

In 1.55, in file boost/intrusive/list.hpp, in function list_impl::iterator_to(): when list_impl is instantiated with stateful value traits, the function attempts to call a non-static member without an object.

The problem is that list_impl does not derive from value_traits, instead, only its member data_ derives from value_traits. Then, inside the non-static iterator_to(), the syntax real_value_traits::to_node_ptr() is incorrect. In contrast, e.g., bstbase3 does derive from value_traits, and there the same syntax works just fine.

I'm attaching a file demonstrating the bug. The file contains the sample code at the bottom of http://www.boost.org/doc/libs/1_55_0/doc/html/intrusive/value_traits.html with a single line modification invoking iterator_to(). I'll create a pull request.

Attachments (1)

bug.boost-intrusive-list.cpp (2.7 KB ) - added by Matei David <matei@…> 9 years ago.

Download all attachments as: .zip

Change History (5)

by Matei David <matei@…>, 9 years ago

comment:1 by Matei David <matei@…>, 9 years ago

comment:2 by Ion Gaztañaga, 9 years ago

Thanks for the report. The bug is also present in other containers, which shows that stateful value traits are not properly tested.

I also think that all "to_value_ptr" and "to_node_ptr" functions should be const as they are used to implement iterators (and operator-> is a const function and must call "to_value_ptr" with a non-const node) and a node<->conversion should not modify the traits. Do you agree with this?

comment:3 by Matei David <matei@…>, 9 years ago

Yes, sounds reasonable. Sorry I didn't look at the other containers, I'm only using lists and rbtrees. I'll cancel the pull request because I noticed you have a more thorough fix in 22973145aaa5

comment:4 by Ion Gaztañaga, 8 years ago

Resolution: fixed
Status: newclosed

Closed as it was fixed in 22973145aaa5. Thanks.

Note: See TracTickets for help on using tickets.