
19 Apr
2006
19 Apr
'06
9:08 p.m.
Alain Cormier wrote:
So, can I conclude that it is a bad behavior in boost::weak_ptr? For now, I have simply changed add_ref_lock to :
long tmp2 = tmp + 1; if(InterlockedCompareExchange ( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true;
This way, VC6 doesn't optimise the return value of InterlockedCompareExchange and the disassembly looks ok. Can I expect this workaround (or any better) in boost in a near future so that weak_ptr truly work with VC6 in release and multi-threaded environment?
I have applied your fix. It will be included in the upcoming release 1.34. Thanks for the report!