$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2007-06-04 11:10:31
Hi Zeljko,
Zeljko Vrba wrote:
> 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.
Now I must confess it: Boost.Intrusive uses a non-standard and 
non-portable hack to make member hooks as small as base hooks. This hack 
uses the fact that for a member stored in a class or in a superclass 
without any virtual inheritance relationship a pointer to member is just 
  the offset of that member in the class. This offset is encoded 
differently for different compilers. If you see the file 
boost/intrusive/detail/parent_from_member.hpp you have the following 
function:
template<class Parent, class Member>
std::size_t offset_from_pointer_to_member(const Member Parent::* 
ptr_to_member)
{
    //The implementation of a pointer to member is compiler dependent.
    #if defined(BOOST_MSVC)  || defined(__GNUC__) || \
        defined(BOOST_INTEL) || defined(__HP_aCC) || \
        defined(__EDG_VERSION__)
    //This works with gcc, msvc, edg, ac++
    return *(const std::size_t*)(const void*)&ptr_to_member;
    #else
    //This is the traditional C-front approach: CW 9.4, dmc
    return *(const std::size_t*)(const void*)&ptr_to_member - 1;
    #endif
}
This function takes a pointer to member and tries to guess the offset 
between the class that owns the member and the member. As you can see, 
for Visual, Intel and GCC a pointer to data member it's just the offset. 
For compilers like DMC and CW is the offset minus 1.
Since I don't have access to a SunCC compiler you will need to help me 
discover how SunCC implements pointer to data members. I will need for 
example the size of a pointer to data member (a simple 
sizeof(ptr_to_member) would be enough), and what the binary value of of 
that pointer to member for different layouts, say:
struct klass { 
 
     void *data_klass[N]; 
 
     boost::intrusive::list_member_hook<> hook_; 
 
 
 
                                                     typedef 
boost::intrusive::list< 
 
         boost::intrusive::list_member_hook<>::value_traits< 
 
             klass, &klass::hook_>, 
 
         false> list; 
 
};
changing the value of N. Willing to help?
Regards,
Ion
P.S.: I'm not sure if EDG-based compilers and HP compiler work because I 
don't have such compilers. If someone wants to help on those, I would be 
glad.