Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-12-12 09:25:25

Eyal Fink wrote:
> I am using boost share_ptr and I have a very strange problem. it looks
> to me more like a compiler problem but since it is a boost code I
> decided to post it here. I haven't succeeded to creating a small example
> which I can post here and demonstrate the problem (I know it is hard to
> help that way but I am working on creating an example) so I will just
describe it.
> The symptom is that the shared_ptr call the delete on a random pointer.
> Going into the shared_ptr and shared_count objects, I sow that the ptr
> field of sp_counted_base_impl has a wrong value. I have added prints
> out all over the code and saw that inside the constructor of
> sp_counted_base_impl the value is set correctly but on the return when I
> try to look at the value and it is a wrong value. adding some more
> prints I saw that inside the shared_count constructor:
> template<class P, class D> shared_count(P p, D d)
> when casting pi_ to (sp_counted_base_impl<P, D>*) and calling a member
> function, the sizeof(*this) in side the member function is not the same
> every time (resulting with a different address to ptr and thus different
> value).
> the problem occurs only when compiling -O

Very odd; looks like either optimizer problem or ABI mismatch. Have you
tried g++ 3.2.3 or 3.3.2?

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at