Robert Shearman wrote:

Ref counts can be assumed to be between 0 and MAXLONG, so the fact that LONG is signed isn't important.

NO. The DCOM spec says that STDOBJREF::cPublicRefs is unsigned, therefore the ref counts can be assumed to be up to MAXULONG. Therefore, this change is incorrect and it would lead to subtle signedness errors.

Do you have a specific example of these errors?

The only operations that are done (and should be done) on ref counts are initialization, InterlockedIncrement and InterlockedDecrement. asm generated will be exactly the same.

In the highly unlikely case that the refcount passes MAXLONG, the behaviour will still be correct, but if refcounts are getting up that high, then you need to start worrying about them wrapping around to zero anyway.

Casts are more problematic than the problems that you're imagining.

Mike


Reply via email to