Boost.Unordered throws 64-bit portability warnings

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?

On Thu, May 21, 2009 at 2:07 PM, Lindley M French
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

2009/5/21 Dominique Devienne
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
Doesn't 'boost::hash_combine(seed, member_)' work? I'll have a look at the warning when I get the chance, but AFAICT they're wrong since when compiling for 64-bit a different overload or template resolution would be chosen. Daniel

On Thu, May 21, 2009 at 2:36 PM, Daniel James
2009/5/21 Dominique Devienne
: 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
Doesn't 'boost::hash_combine(seed, member_)' work?
Never meant to imply it doesn't work, sorry. It's just to avoid the warning, while not "breaking" the 64-bit compiles by doing the narrowing-on-64-bit cast unconditionally. Could have snuffed the VS2005 warning too. But it's an annoying warning.
I'll have a look at the warning when I get the chance, but AFAICT they're wrong since when compiling for 64-bit a different overload or template resolution would be chosen.
No argument from me there ;-) --DD

2009/5/21 Dominique Devienne
On Thu, May 21, 2009 at 2:36 PM, Daniel James
wrote: 2009/5/21 Dominique Devienne
: #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
Doesn't 'boost::hash_combine(seed, member_)' work?
Never meant to imply it doesn't work, sorry.
I wasn't clear, you're calling 'boost::hash_combine(seed, hash_value(member_))', but normally you should be able to just call 'boost::hash_combine(seed, member_)' - hash_combine should hash 'member_' for you. Daniel

2009/5/21 Lindley M French
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.
This should be fixed in trunk now. I just put in some pragmas as I can't come up with a reasonable way to make Visual C++ happy. Daniel
participants (3)
-
Daniel James
-
Dominique Devienne
-
Lindley M French