|
Boost Users : |
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-04-11 12:02:50
On Wed, April 11, 2007 17:51, Oleg V. Zhylin wrote:
> Hi,
>
> Is there a reason to use type int in the code at line 487 in
> oserializer.hpp?
>
> int count = sizeof(t) / (
> static_cast<const char *>(static_cast<const void *>(&t[1]))
>
> - static_cast<const char *>(static_cast<const void
> *>(&t[0]))
>
> C++ standard draft states in section 5.3.3 [expr.sizeof]
>
> The result is a constant of an implementation-defined
> type which is the same type as that which is named
> size_t in the standard header <cstddef>(18.1).
I assume otherwise you will get a warning, that a sign can be lost through the assignment. The
problem here is that expression (type* - type*) results not in an unsigned type (size_t) but a
signed difference type. If you divide unsigned value through a signed value you get a signed
value. And then you would (according to your suggestion) assign it to an unsigned value =>
warning.
With Kind Regards,
Ovanes Markarian
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