Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-13 Thread ZaeX
Oh, Thank god, so at least it is not only me. :) I just double-check this, and this behavior not only happened in debug build, it will happen in release build too, But the pointer showing up would not be 0x but something arbitrary. P.S.: I have already changed to follow you guys' advices

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-13 Thread athor
I just reproduced the behaviour. Out of habit, I compiled with release the last time. Using a debug build, I get the same behaviour (using const&, non-const& etc). I'm guessing this is a case of "undefined behaviour" resulting from mixing Debug/Release dll's. Changing to Release (or reading Dave

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-13 Thread athor
That is very very strange. Removing const should not change anything. If it does... well... black magic? The debugging link Dave provided is very important if you must compile debug versions. I remember something about not mixing debug/release versions of python but I just avoid the issue by never

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-12 Thread ZaeX
No, I compiled boost.python with just ' --with-python '. and I just made a last try to change the 'shared_ptr const& ' to 'shared_ptr&', and things suddenly become right. ^_^ well I don't quite understand what's going on inside though. maybe 'shared_ptr const&' made temp copy (?)

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-12 Thread David Abrahams
on Thu Mar 12 2009, ZaeX wrote: > I just built the boost.python 1.36 with Python2.6.1 and tried again, and it > still turned out to be 0x in debug build. Have you read http://www.boost.org/doc/libs/1_38_0/libs/python/doc/building.html#python-debugging-builds ? -- Dave Abrahams BoostPr

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-12 Thread ZaeX
I just built the boost.python 1.36 with Python2.6.1 and tried again, and it still turned out to be 0x in debug build. And I made sure this is not caused by 'a = B(a)'-like typo. Maybe it's something concerning the project setting or something went wrong with my compiler(?) Whatever, I thin

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-12 Thread David Abrahams
on Thu Mar 12 2009, athor wrote: > * You don't *need* a const& to break cyclic reference. Passing a shared_ptr > by value works too. And that's almost always a better idea. If you *do* have a reference cycle, consider weak_ptr instead. -- Dave Abrahams BoostPro Computing http://www.boostpro.

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-12 Thread athor
zaexage wrote: > > I got a 'class Manager' which contains a std::set of shared_ptr; > and 'class Entity' has a auto_ptr as member > and 'class StateMachine' needs shared_ptr as member variable to > access some functions outside. > > So, in order to break cyclic reference, I make the StateM

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-12 Thread ZaeX
Hi, I copied the code and tried again, and find out that this 0x problem would still occur at debug build, and when I switched to Release build, the 'b.ShowPtr()' gave a wrong address. But since this code is correct at your side, I think it's possibly because the precompiled boost.python

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-12 Thread athor
Hi, I just tried your example and could not reproduce the "feature". I made a few minor modifications like fixing typos and adding a cout statement in the constructor of A but nothing that should affect the result. A few things that could cause you problems: * Passing shared_ptr by reference and

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-12 Thread ZaeX
Thanks Roman, I think I will take the advice to try working around this problem. On Thu, Mar 12, 2009 at 1:17 PM, Roman Yakovenko wrote: > 2009/3/11 ZaeX : > > Hi,Roman: > > > > I have tried adding call policy on my constructor, but I'm really no good > at > > this. > > I have tried all the combi

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-11 Thread Roman Yakovenko
2009/3/11 ZaeX : > Hi,Roman: > > I have tried adding call policy on my constructor, but I'm really no good at > this. > I have tried all the combinations below but none of them work: > > init const& >()[with_custodian_and_ward_postcall<0, 2> >()] > init const& >()[with_custodian_and_ward_postcall<1

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-11 Thread ZaeX
Hi,Roman: I have tried adding call policy on my constructor, but I'm really no good at this. I have tried all the combinations below but none of them work: - init const& >()[with_custodian_and_ward_postcall<0, 2> >()] - init const& >()[with_custodian_and_ward_postcall<1, 2> >()] -

Re: [C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-10 Thread Roman Yakovenko
2009/3/11 ZaeX : > Hi, All: > > I used a "shared_ptr const&" to store a ref of A in B; > Well, the constructor of B seems ok, the share_ptr seems to be well > initialized; > but after the constructor, I found the the pointer silently become > 0x > > / bel

[C++-sig] why does the "shared_ptr const&" silently become 0xCCCCCCCC

2009-03-10 Thread ZaeX
Hi, All: I used a "shared_ptr const&" to store a ref of A in B; Well, the constructor of B seems ok, the share_ptr seems to be well initialized; but after the constructor, I found the the pointer silently become 0x / below are the simplified class defin