Boost logo

Boost Users :

From: Boris Gubenko (Boris.Gubenko_at_[hidden])
Date: 2007-06-04 15:31:27


Ion Gaztanaga wrote:
> If the distance is equal to the raw values ...

It is equal:

bash-2.03$ aCC -I./boost -DNN=10 x.cpp && a.out
4 44
44
bash-2.03$ aCC -I./boost -DNN=20 x.cpp && a.out
4 84
84
bash-2.03$ aCC -I./boost -DNN=10 +DD64 x.cpp && a.out
8 88
88
bash-2.03$ aCC -I./boost -DNN=20 +DD64 x.cpp && a.out
8 168
168
bash-2.03$

x.cpp
-----
#include <iostream>
#include <boost/intrusive/list.hpp>
#include <cstddef>

struct klass {
    void *data_[NN];
    char ch_;
    boost::intrusive::list_member_hook<> hook_;
};

int main(void)
{
    using std::cout;
    using std::endl;
    klass k;
    ptrdiff_t distance = (char*)&k.hook_ - (char*)&k;
    boost::intrusive::list_member_hook<> klass::*ptr = &klass::hook_;
    cout << sizeof(ptr) << ' ' << offsetof(klass, hook_) << endl;
    cout << distance << endl;
    return 0;
}

----- Original Message -----
From: "Ion Gaztañaga" <igaztanaga_at_[hidden]>
To: "Boost User List" <boost-users_at_[hidden]>
Sent: Monday, June 04, 2007 3:01 PM
Subject: Re: [Boost-users] [boost.intrusive] Assertion failure with SunCC

> Boris Gubenko wrote:
>> Ion Gaztanaga wrote:
>>> 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.
>>
>> Below are the results on HP-UX/ia64 in 32- and 64-bit pointer mode using
>> the program posted by Zeljko Vrba.
>>
>> The compiler on HP-UX/ia64 is EDG-based so checking both __HP_aCC and
>> __EDG_VERSION__ in boost/intrusive/detail/parent_from_member.hpp is
>> reduntant.
>>
>> bash-2.03$ aCC -V
>> aCC: HP C/aC++ B3910B A.06.14 [Feb 22 2007]
>> bash-2.03$ aCC -I./boost -DNN=10 x.cpp && a.out
>> 4 44
>> bash-2.03$ aCC -I./boost -DNN=20 x.cpp && a.out
>> 4 84
>> bash-2.03$ aCC -I./boost -DNN=10 +DD64 x.cpp && a.out
>> 8 88
>> bash-2.03$ aCC -I./boost -DNN=20 +DD64 x.cpp && a.out
>> 8 168
>> bash-2.03$
>
> So it seems that the compiler aligns the hook to 4 bytes:
>
> void *data_[NN]; //4*NN bytes
> char ch_; //1 byte plus alignment
>
> so the trick used to extract the offset in parent_from_member function
> is adequate. But the regression tests for Intrusive with HP aCC:
>
> http://engineering.meta-comm.com/boost-regression/CVS-HEAD/developer/intrusive.html
>
> seems to fail in tests using member hooks. A bit strange. Can you check
> the real distance between members with something like:
>
> int main(void)
> {
> using std::cout;
> using std::endl;
> klass k;
> cout << ((char*)k.hook_ - (char*)k) << endl;
> return 0;
> }
>
> If the distance is equal to the raw values extracted from the pointer to
> data member, then regression test failures might be provoked by another
> library bug.
>
> Regards,
>
> Ion
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>


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