On 3/22/07, Joaquín Mª López Muñoz
Hello Daniel, I think you are misunderstanding the problem.: the warning is *not* valid because it happens in 32 bit mode, where std::size_t is a typedef for unsigned int (no longs involved).
The warning only ever happens in 32bit mode - it warns about what *would* happen if compiled in 64 bit mode. So the warning, in general, is valid.
The problem is that /Wp64 mode is too smart (or too dumb if you want) and sees a potential problem in casting a std::size_t to an unsigned int (which are the same in 32bit mode) because that cast would pose problems in 64 bit mode. IMHO the right course of action is to not provide overloads for size_t, provide thenm for long and long long types, so guaranteeing that size_t will be covered by some overload either in 32 or 64 bit mode, and then disabling the warning with a
// boost/hash/hash.hpp #pragma warning(push) #pragma warning(disable:4267) ... #pragma warning(pop)
because even if you've got everything covered /Wp64 won't be able to see it. A good thing about the proposed pragma solution is that by using push/pop facilities you eliminate the warnings inside Boost.Hash without imposing a global warning disabling to the user.
That sounds exactly right. In this case the warning is NOT valid because you've covered all sizes via the various overloads, but the warning can't see that. So use pragmas to shut it off - but make sure the pragmas are as close as possible to the code in question. Alternatively, since size_t is guaranteed to be the same as some integer, you could make sure there is a size_t version, and only do an int or long version if they are NOT size_t. But that seems hokey just to avoid a warning.
HTH,
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Tony