[numeric_cast] unwished warnings
Hello!
Using numeric_cast I face a warning in MSVC 8.0 Express Edition
e:\libraries\boost\include\boost-1_35\boost\numeric\conversion\cast.hpp(41) : warning C4267:
'return' : conversion from 'size_t' to 'Uint32', possible loss of data
e:\projects\fundamental_type_factory.cpp(62) : see reference to function template
instantiation 'Target
boost::numeric_cast
Ovanes Markarian schrieb:
Using numeric_cast I face a warning in MSVC 8.0 Express Edition
e:\libraries\boost\include\boost-1_35\boost\numeric\conversion\cast.hpp(41) : warning C4267: 'return' : conversion from 'size_t' to 'Uint32', possible loss of data [...]
Trying to compile without warnings I am wondering about this warning, since I use the cast to raise an exception at runtime if data are lost. Is it logical?
You should show your code lines that generate this warning. In Visual Studio 2005, when creating a project, the compiler enables the "64 bit compatibility warnings" switch. And on the 64 bit compiler, size_t has 63 bits, an Uint32 still has 32 bits. That is why the compiler warns about a possible data loss. Are you converting from size_t (or any of the container::size_types) to Uint32? Norbert
participants (2)
-
Norbert Unterberg
-
Ovanes Markarian