Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Unordered throws 64-bit portability warnings
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2009-05-21 15:24:12


On Thu, May 21, 2009 at 2:07 PM, Lindley M French <lfrench1_at_[hidden]> wrote:
> I've noticed on Visual Studio 2005 that I get a slew of warnings from Boost/unordered/detail/hash_table_impl.hpp when I build with "Detect 64-bit portability issues" turned on. In particular at the moment I'm seeing the following warning:
>
> boost/unordered/detail/hash_table_impl.hpp(1569) : warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int', possible loss of data
>
> And the same on lines 1328, 1569, 1541, 1799, and 1763.
>
> I doubt this poses a real problem, but with hash tables you never know. I'd prefer not to see warnings when I build. Can this be fixed, and can regression testing using this build setting be added to the mix in general?

FWIW, I'm getting these as well when using
boost::hash_combine(hash_value(this->member_)); to implement hashes
for my classes. We also use VS2005 with the compiler switch that
raises these warnings. My work around below is not pretty... --DD

#if ACME_SIZEOF_SIZE_T == 4
        // Avoid warning C4267: 'argument' :
        // conversion from 'size_t' to 'unsigned int', possible loss of data
        boost::hash_combine(
            seed, static_cast<unsigned int>(hash_value(member_))
        );
#else
        boost::hash_combine(seed, hash_value(member_));
#endif


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