Ticket #9940: bi-list-bug.cpp

File bi-list-bug.cpp, 1.0 KB (added by Matei David <matei@…>, 9 years ago)

demonstrates bug

Line 
1// compile with:
2// g++ -std=c++11 -Wall -Wextra -pedantic -g3 -O0 -I${BOOST_INCLUDE}
3
4#include <iostream>
5#include <boost/intrusive/list.hpp>
6#include <boost/intrusive/trivial_value_traits.hpp>
7
8namespace bi = boost::intrusive;
9
10struct A
11{
12 A(int val = 0)
13 : val_(val), prev_(nullptr), next_(nullptr) {}
14 ~A()
15 {
16 prev_ = nullptr; next_ = nullptr;
17 }
18 int val_;
19 A* prev_;
20 A* next_;
21};
22
23struct Node_Traits
24{
25 typedef A node;
26 typedef A* node_ptr;
27 typedef const A* const_node_ptr;
28 static node *get_next(const node *n) { return n->next_; }
29 static void set_next(node *n, node *next) { n->next_ = next; }
30 static node *get_previous(const node *n) { return n->prev_; }
31 static void set_previous(node *n, node *prev) { n->prev_ = prev; }
32};
33
34typedef bi::trivial_value_traits< Node_Traits, bi::safe_link > Value_Traits;
35typedef bi::list< A, bi::value_traits< Value_Traits > > list_t;
36
37int main()
38{
39 {
40 list_t l;
41 (void)l;
42 }
43 std::cout << "never reached\n";
44}