Opened 9 years ago
Closed 8 years ago
#9650 closed Bugs (fixed)
intrusive list with stateful value traits
Reported by: | 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)
Change History (5)
by , 9 years ago
Attachment: | bug.boost-intrusive-list.cpp added |
---|
comment:1 by , 9 years ago
comment:2 by , 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 , 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 , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Closed as it was fixed in 22973145aaa5. Thanks.
Pull request here: https://github.com/boostorg/intrusive/pull/1