compiler warnings with boost_1_53_0 gzip
#include <boost/iostreams/filtering_stream.hpp> #include <boost/iostreams/filter/gzip.hpp> int main() { using namespace boost::iostreams; filtering_ostream filter; filter.push(gzip_decompressor()); // All warnings are from this line return 0; } 1>------ Build started: Project: test, Configuration: Release Win32 ------ 1> main.cpp 1>D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(599): warning C4244: 'argument' : conversion from 'std::streamsize' to 'unsigned int', possible loss of data 1> D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(597) : while compiling class template member function 'bool boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>::putback(char)' 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(512) : see reference to function template instantiation 'bool boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>::putback(char)' being compiled 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(465) : see reference to class template instantiation 'boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>' being compiled 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/read.hpp(214) : see reference to function template instantiation 'std::streamsize boost::iostreams::basic_gzip_decompressor<>::read<Source>(Source &,boost::iostreams::basic_gzip_decompressor<>::char_type *,std::streamsize)' being compiled 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/read.hpp(214) : see reference to function template instantiation 'std::streamsize boost::iostreams::basic_gzip_decompressor<>::read<Source>(Source &,boost::iostreams::basic_gzip_decompressor<>::char_type *,std::streamsize)' being compiled 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/read.hpp(57) : see reference to function template instantiation 'std::streamsize boost::iostreams::detail::read_filter_impl<boost::iostreams::multichar_tag>::read<boost::iostreams::basic_gzip_decompressor<>,Source>(T &,Source &,char *,std::streamsize)' being compiled 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char>, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/detail/adapter/concept_adapter.hpp(253) : see reference to function template instantiation 'std::streamsize boost::iostreams::read<Filter,Source>(T &,Source &,char *,std::streamsize)' being compiled 1> with 1> [ 1> Filter=boost::iostreams::basic_gzip_decompressor<>, 1> Source=boost::iostreams::detail::linked_streambuf<char>, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/detail/adapter/concept_adapter.hpp(77) : see reference to function template instantiation 'std::streamsize boost::iostreams::detail::flt_wrapper_impl<boost::iostreams::input>::read<boost::iostreams::basic_gzip_decompressor<>,Source>(Filter &,Source *,char *,std::streamsize)' being compiled 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char>, 1> Filter=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/detail/streambuf/indirect_streambuf.hpp(258) : see reference to function template instantiation 'std::streamsize boost::iostreams::detail::concept_adapter<T>::read<boost::iostreams::detail::linked_streambuf<Ch>>(char *,std::streamsize,Source *)' being compiled 1> with 1> [ 1> T=component_type, 1> Ch=char, 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/detail/streambuf/indirect_streambuf.hpp(258) : see reference to function template instantiation 'std::streamsize boost::iostreams::detail::concept_adapter<T>::read<boost::iostreams::detail::linked_streambuf<Ch>>(char *,std::streamsize,Source *)' being compiled 1> with 1> [ 1> T=component_type, 1> Ch=char, 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/detail/streambuf/indirect_streambuf.hpp(237) : while compiling class template member function 'int boost::iostreams::detail::indirect_streambuf<T,Tr,Alloc,Mode>::underflow(void)' 1> with 1> [ 1> T=component_type, 1> Tr=std::char_traits<char>, 1> Alloc=std::allocator<char>, 1> Mode=boost::iostreams::output 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/stream_buffer.hpp(66) : see reference to class template instantiation 'boost::iostreams::detail::indirect_streambuf<T,Tr,Alloc,Mode>' being compiled 1> with 1> [ 1> T=component_type, 1> Tr=std::char_traits<char>, 1> Alloc=std::allocator<char>, 1> Mode=boost::iostreams::output 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/chain.hpp(257) : see reference to class template instantiation 'boost::iostreams::stream_buffer<T,Tr,Alloc,Mode>' being compiled 1> with 1> [ 1> T=component_type, 1> Tr=std::char_traits<char>, 1> Alloc=std::allocator<char>, 1> Mode=boost::iostreams::output 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/chain.hpp(216) : see reference to function template instantiation 'void boost::iostreams::detail::chain_base<Self,Ch,Tr,Alloc,Mode>::push_impl<T>(const T &,std::streamsize,std::streamsize)' being compiled 1> with 1> [ 1> Self=boost::iostreams::chain<boost::iostreams::output,char,std::char_traits<char>,std::allocator<char>>, 1> Ch=char, 1> Tr=std::char_traits<char>, 1> Alloc=std::allocator<char>, 1> Mode=boost::iostreams::output, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/chain.hpp(216) : see reference to function template instantiation 'void boost::iostreams::detail::chain_base<Self,Ch,Tr,Alloc,Mode>::push_impl<T>(const T &,std::streamsize,std::streamsize)' being compiled 1> with 1> [ 1> Self=boost::iostreams::chain<boost::iostreams::output,char,std::char_traits<char>,std::allocator<char>>, 1> Ch=char, 1> Tr=std::char_traits<char>, 1> Alloc=std::allocator<char>, 1> Mode=boost::iostreams::output, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/chain.hpp(499) : see reference to function template instantiation 'void boost::iostreams::detail::chain_base<Self,Ch,Tr,Alloc,Mode>::push<T>(const T &,std::streamsize,std::streamsize,void *)' being compiled 1> with 1> [ 1> Self=boost::iostreams::chain<boost::iostreams::output,char,std::char_traits<char>,std::allocator<char>>, 1> Ch=char, 1> Tr=std::char_traits<char>, 1> Alloc=std::allocator<char>, 1> Mode=boost::iostreams::output, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/chain.hpp(499) : see reference to function template instantiation 'void boost::iostreams::detail::chain_base<Self,Ch,Tr,Alloc,Mode>::push<T>(const T &,std::streamsize,std::streamsize,void *)' being compiled 1> with 1> [ 1> Self=boost::iostreams::chain<boost::iostreams::output,char,std::char_traits<char>,std::allocator<char>>, 1> Ch=char, 1> Tr=std::char_traits<char>, 1> Alloc=std::allocator<char>, 1> Mode=boost::iostreams::output, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/chain.hpp(488) : see reference to function template instantiation 'void boost::iostreams::detail::chain_client<Chain>::push_impl<T>(const T &,std::streamsize,std::streamsize)' being compiled 1> with 1> [ 1> Chain=boost::iostreams::chain<boost::iostreams::output,char,std::char_traits<char>,std::allocator<char>>, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/chain.hpp(488) : see reference to function template instantiation 'void boost::iostreams::detail::chain_client<Chain>::push_impl<T>(const T &,std::streamsize,std::streamsize)' being compiled 1> with 1> [ 1> Chain=boost::iostreams::chain<boost::iostreams::output,char,std::char_traits<char>,std::allocator<char>>, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> main.cpp(9) : see reference to function template instantiation 'void boost::iostreams::detail::chain_client<Chain>::push<boost::iostreams::basic_gzip_decompressor<>>(const T &,std::streamsize,std::streamsize,void *)' being compiled 1> with 1> [ 1> Chain=boost::iostreams::chain<boost::iostreams::output,char,std::char_traits<char>,std::allocator<char>>, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1> main.cpp(9) : see reference to function template instantiation 'void boost::iostreams::detail::chain_client<Chain>::push<boost::iostreams::basic_gzip_decompressor<>>(const T &,std::streamsize,std::streamsize,void *)' being compiled 1> with 1> [ 1> Chain=boost::iostreams::chain<boost::iostreams::output,char,std::char_traits<char>,std::allocator<char>>, 1> T=boost::iostreams::basic_gzip_decompressor<> 1> ] 1>D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(608): warning C4244: 'argument' : conversion from 'std::streamsize' to 'unsigned int', possible loss of data 1> D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(607) : while compiling class template member function 'void boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>::putback(const std::basic_string<_Elem,_Traits,_Alloc> &)' 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char>, 1> _Elem=char, 1> _Traits=std::char_traits<char>, 1> _Alloc=std::allocator<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(491) : see reference to function template instantiation 'void boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>::putback(const std::basic_string<_Elem,_Traits,_Alloc> &)' being compiled 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char>, 1> _Elem=char, 1> _Traits=std::char_traits<char>, 1> _Alloc=std::allocator<char> 1> ] 1>D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(621): warning C4244: 'argument' : conversion from 'const std::streamsize' to 'unsigned int', possible loss of data 1> D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(620) : while compiling class template member function 'std::basic_string<_Elem,_Traits,_Alloc> boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>::unconsumed_input(void) const' 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char>, 1> _Alloc=std::allocator<char>, 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(522) : see reference to function template instantiation 'std::basic_string<_Elem,_Traits,_Alloc> boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>::unconsumed_input(void) const' being compiled 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char>, 1> _Alloc=std::allocator<char>, 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1>D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(583): warning C4244: 'argument' : conversion from 'std::streamsize' to 'size_t', possible loss of data 1> D:\dev\boost_1_53_0\boost/iostreams/filter/gzip.hpp(574) : while compiling class template member function 'std::streamsize boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>::read(char *,std::streamsize)' 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> D:\dev\boost_1_53_0\boost/iostreams/read.hpp(180) : see reference to function template instantiation 'std::streamsize boost::iostreams::basic_gzip_decompressor<>::peekable_source<Source>::read(char *,std::streamsize)' being compiled 1> with 1> [ 1> Source=boost::iostreams::detail::linked_streambuf<char> 1> ] 1> Generating code 1> Finished generating code 1> test.vcxproj -> D:\dev\projects\test\Release\test.exe ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Why am I getting these warnings?
Answers
This is a signed unsigned warning about the library code. The type std::streamsize is a signed integral type used to represent the number of characters transferred in an I/O operation or the size of an I/O buffer.
Unless your file sizes are more than 2Gb on a 32-bit platform, there is little actual danger of getting bitten by this signed/unsigned conversion. You can disable this warning through a #pragma.