Opened 13 years ago

Last modified 12 years ago

#3194 new Bugs

compiler warnings in VC9

Reported by: kfriddile@… Owned by: Daryle Walker
Milestone: Boost 1.40.0 Component: crc
Version: Boost 1.39.0 Severity: Problem
Keywords: Cc:

Description

The following code under VC9 with warning level 4 produces the warnings below. Warnings are not allowed on my project, and rather than wrapping boost includes with a #pragma directive, I'd rather these warnings just be suppressed in the code that's causing them.

boost::uint32_t GenerateChecksum( const char* data, size_t length ) {

boost::crc_32_type computer;

computer = std::for_each( data,

data + length, computer );

return computer();

}

2>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_39_0\boost/crc.hpp(377) : warning C4245: 'initializing' : conversion from 'int' to 'const boost::detail::mask_uint_t<8>::least', signed/unsigned mismatch 2>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_39_0\boost/crc.hpp(400) : warning C4245: 'initializing' : conversion from 'int' to 'const boost::detail::mask_uint_t<16>::least', signed/unsigned mismatch 2>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_39_0\boost/crc.hpp(574) : warning C4244: 'return' : conversion from 'unsigned int' to 'unsigned char', possible loss of data 2> C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_39_0\boost/crc.hpp(574) : while compiling class template member function 'unsigned char boost::detail::crc_helper<Bits,DoReflect>::index(unsigned int,unsigned char)' 2> with 2> [ 2> Bits=32, 2> DoReflect=true 2> ] 2> C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_39_0\boost/crc.hpp(836) : see reference to class template instantiation 'boost::detail::crc_helper<Bits,DoReflect>' being compiled 2> with 2> [ 2> Bits=32, 2> DoReflect=true 2> ] 2> C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_39_0\boost/crc.hpp(836) : while compiling class template member function 'boost::crc_optimal<Bits,TruncPoly,InitRem,FinalXor,ReflectIn,ReflectRem>::crc_optimal(unsigned int)' 2> with 2> [ 2> Bits=32, 2> TruncPoly=79764919, 2> InitRem=-1, 2> FinalXor=-1, 2> ReflectIn=true, 2> ReflectRem=true 2> ] 2> ..\..\..\..\components\libs\checksum\source\Checksum.cpp(12) : see reference to class template instantiation 'boost::crc_optimal<Bits,TruncPoly,InitRem,FinalXor,ReflectIn,ReflectRem>' being compiled 2> with 2> [ 2> Bits=32, 2> TruncPoly=79764919, 2> InitRem=-1, 2> FinalXor=-1, 2> ReflectIn=true, 2> ReflectRem=true 2> ]

Change History (1)

comment:1 by jonw@…, 12 years ago

For VS9 I did the following changes to crc.hpp (version 1_44_0) to remove the warnings from my code:

line 377: BOOST_STATIC_CONSTANT( least, sig_bits = least( ~0 ) );
line 400: BOOST_STATIC_CONSTANT( least, sig_bits = least( ~0 ) );
line 578: { return static_cast< unsigned char >( x ^ rem ); }

Could you please verify if this is appropriate? I know this would need to be tested for a great number of compilers/platforms.

Note: See TracTickets for help on using tickets.