|
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.
John
-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Peter Dimov
Sent: Wednesday, April 19, 2006 10:45 AM
To: boost-users_at_[hidden]
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
examples we
try. But if we can't think of a better way to work around the issue,
this
may be our best bet.
_______________________________________________
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