Boost Users :
From: John Wilkinson (jwilkinson_at_[hidden])
Date: 2006-04-19 12:34:41
There is a pragma in VC6 that will activate or deactivate optimization.
It can be used to wrap optimization-sensitive blocks of code. I do not
remember what it is, though, and I do not have VC6 handy. I have used
it, and it did alleviate an optimization-related bug.
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Peter Dimov
Sent: Wednesday, April 19, 2006 10:45 AM
Subject: Re: [Boost-users] [weak_ptr] thread safe?
Alain Cormier wrote:
> So, can I conclude that it is a bad behavior in boost::weak_ptr?
No, it is a bug in VC6.
> 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.
I don't think that there is any guarantee that this modification will
reliably produce correct code, even if it happens to work in the
try. But if we can't think of a better way to work around the issue,
may be our best bet.
Boost-users mailing list
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