Unexpected warning relating to boost::function, and size_t / unsigned
Hello,
I'm receiving a compiler warning (MSVC8.0) that does not make sense to
me, and I wonder if this might be a boost related issue:
#include <vector>
#include <functional>
#include
I'd like to join this question.
I've got the same strange behavior when using boost::hash, like this:
std::size_t hash_value(const Command &cmd)
{
return boost::hashstd::size_t()(cmd.id()); // id() returns std::sze_t
}
And I guess, the problem is not in a possible redefinition of size_t -
since everywhere in code the std::size_t is fully qualified...
2008/7/14, Matthew Bourdua
Hello,
I'm receiving a compiler warning (MSVC8.0) that does not make sense to me, and I wonder if this might be a boost related issue:
#include <vector> #include <functional> #include
int main() { std::vector< std::size_t > sizes; std::vector< unsigned > data; boost::function< bool (unsigned, unsigned) > fn = std::greater< unsigned
(); fn( data.front(), 10 ); // NOTE: data is empty - will cause runtime error }
The warning I get is: warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int', possible loss of data referring to the last line in main().
This warning goes away if I do either of the following: - Comment out the std::vector< std::size_t > sizes - this one baffles me. - Use a 'naked' std::greater< unsigned >() instead of a boost::function< bool (unsigned, unsigned) >() object.
I wonder if size_t is somehow redefined in boost in a way that might be causing me some trouble?
Any help would be appreciated, thanks.
Matt _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Igor R escribió:
I'd like to join this question. I've got the same strange behavior when using boost::hash, like this:
std::size_t hash_value(const Command &cmd) { return boost::hashstd::size_t()(cmd.id()); // id() returns std::sze_t }
And I guess, the problem is not in a possible redefinition of size_t - since everywhere in code the std::size_t is fully qualified...
This is not really a problem but a misguided warning by MSVC when using the /Wp64 compiler option (Detect 64-Bit Portability Issues). For more info please read the thread starting at: http://lists.boost.org/boost-users/2007/03/26227.php Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Now I got it... Thanks!
2008/7/14, joaquin@tid.es
This is not really a problem but a misguided warning by MSVC when using the /Wp64 compiler option (Detect 64-Bit Portability Issues). For more info please read the thread starting at:
http://lists.boost.org/boost-users/2007/03/26227.php
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (3)
-
Igor R
-
joaquin@tid.es
-
Matthew Bourdua