Boost logo

Boost Users :

From: Michael Linck (mgl_at_[hidden])
Date: 2007-11-09 18:40:40


I'm surprised this didn't seem to get answered. I wouldn't worry about
the warning in your case. Here's the difference: size_t is unsigned,
streamsize is signed. This means that if they're both the same
datawidth - which is likely - you'll get the warning below because the
range of size_t tops out at a *much* higher value than that of
streamsize.

If you're really concerned about this you may be able to use boost
numerics to validate that the value of size_t is actually within the
range of streamsize. To merely quell the warning, an explicit cast
should do the trick.

mike

On Wed, 2007-10-31 at 11:57 -0500, Dave Nay wrote:
> Ok....this is really confusing.
>
> I successfully created a small test project several months ago using the
> Boost Serialization library to serialize some binary data. I am now
> attempting to add binary serialization to a production project, and I
> receive a bunch of compiler warnings.
>
> I can still compile and execute the test application with no warnings or
> errors.
>
> I am using VS2005 with boost 1.34.1
>
> I have included the first few compiler warnings below...
>
> 1>C:\Program
> Files\boost\boost_1_34_1\boost/archive/basic_binary_oprimitive.hpp(136) :
> warning C4267: 'argument' : conversion from 'size_t' to 'std::streamsize',
> possible loss of data
> 1> C:\Program
> Files\boost\boost_1_34_1\boost/archive/basic_binary_oprimitive.hpp(120) :
> while compiling class template member function 'void
> boost::archive::basic_binary_oprimitive<Archive,Elem,Tr>::save_binary(const
> void *,size_t)'
> 1> with
> 1> [
> 1> Archive=boost::archive::binary_oarchive,
> 1> Elem=char,
> 1> Tr=std::char_traits<char>
> 1> ]
> 1> C:\Program
> Files\boost\boost_1_34_1\boost/archive/detail/oserializer.hpp(91) : see
> reference to function template instantiation 'void
> boost::archive::basic_binary_oprimitive<Archive,Elem,Tr>::save<T>(const T
> &)' being compiled
> 1> with
> 1> [
> 1> Archive=boost::archive::binary_oarchive,
> 1> Elem=char,
> 1> Tr=std::char_traits<char>,
> 1> T=unsigned char
> 1> ]
> 1> C:\Program
> Files\boost\boost_1_34_1\boost/archive/detail/oserializer.hpp(244) : see
> reference to function template instantiation 'void
> boost::archive::save_access::save_primitive<Archive,T>(Archive &,const T &)'
> being compiled
> 1> with
> 1> [
> 1> Archive=boost::archive::binary_oarchive,
> 1> T=unsigned char
> 1> ]
>
> Thanks,
> Dave
>
> --
> Dave Nay
> CIVision, LLC
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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