MT-safe string, part 1
Nathan Myers
ncm@nospam.cantrip.org
Sat Apr 1 00:00:00 GMT 2000
On Wed, Mar 15, 2000 at 05:55:44PM -0500, George T. Talbot wrote:
> In your patch, I see you changed _M_state from int to uint32_t.
>
> Sure you meant to do that? Here's your comparison:
>
> if (exchange_and_add(&_M_state, -1) <= 0)
>
> Unsigned will never be < 0, right?
Right. It should be something like
if (int(exchange_and_add(reinterpret_cast<uint32_t*>(&_M_state), -1)) <= 0)
Better, the direct uses of _M_state should be replaced by
functions which hide all the casts & similar magic. I will
prepare a new patch.
Nathan Myers
ncm@nospam.cantrip.org
More information about the Libstdc++
mailing list