|
Boost Users : |
From: Zeljko Vrba (zvrba_at_[hidden])
Date: 2007-06-03 15:08:20
The following simple program crashes with assertion failure when compiled under
Solaris 11 with SunCC: Sun C++ 5.8 Patch 121018-10 2007/02/21
Assertion failed: node_algorithms::unique(to_insert),
file boost/boost/intrusive/list.hpp, line 168
I'm using the latest Boost.Intrusive from CVS (snapshot taken 2007-06-03).
I have tracked the problem, but I don't know wheter it's the code or compiler
problem; see below the code for cause.
== Begin code
// Program to demonstrate a bug with SunCC and member hooks.
#include <boost/intrusive/list.hpp>
struct klass {
void *data_klass;
boost::intrusive::list_member_hook<> hook_;
typedef boost::intrusive::list<
boost::intrusive::list_member_hook<>::value_traits<
klass, &klass::hook_>,
false> list;
};
static klass Gd;
static klass::list Gl;
int main(void)
{
=> Gl.push_back(Gd);
return 0;
}
== End code
When the program is started, the hook's prev_ and next_ members are initialized
correctly to &Gd.hook_ (0x8062dd8). The member_value_traits instance is by dbx
resolved to
boost::intrusive::detail::member_value_traits<
klass,boost::intrusive::list_member_hook<
(boost::intrusive::linking_policy)1,void*>,
klass::hook_>::to_node_ptr
^^^^^^^^^^^^
Corresponds to the template P parameter.
The statement MemberHookType* result = &(value.*P);
sets result to 0x8062dd4 (4 bytes off from the hooks address). Finally, in
push_back method, the to_insert value receives 0x8062dd4 which equals &Gd
(ie. it points to the start of the object) instead of &Gd.hook_.
Should this be reported as a compiler bug?
BTW, I'll try using base hooks as a workaround.
(PS: the code works fine with gcc4.2)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net