[Boost-bugs] [Boost C++ Libraries] #1229: [GCC] compiler warning: comparison between signed and unsigned integer expressions

Subject: [Boost-bugs] [Boost C++ Libraries] #1229: [GCC] compiler warning: comparison between signed and unsigned integer expressions
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-09-04 06:54:09


#1229: [GCC] compiler warning: comparison between signed and unsigned integer
expressions
----------------------------------------------------------+-----------------
 Reporter: Dean Michael Berris <mikhailberis_at_[hidden]> | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost Development Trunk | Severity: Problem
 Keywords: serialization, compiler warnings |
----------------------------------------------------------+-----------------
 I've attached the warning generated during compilation of the
 Serialization library.

 {{{
 gcc.compile.c++
 /usr/local/lib/boost/bin.v2/libs/serialization/build/gcc-4.1.2/debug/link-
 static/optimization-speed/threading-multi/binary_iarchive.o
 /usr/local/lib/boost/boost/archive/basic_binary_iprimitive.hpp: In member
 function void boost::archive::basic_binary_iprimitive<Archive, Elem,
 Tr>::load_binary(void*, size_t) [with Archive =
 boost::archive::naked_binary_iarchive, Elem = char, Tr =
 std::char_traits<char>]:
 /usr/local/lib/boost/libs/serialization/src/binary_iarchive.cpp:24:
 instantiated from here
 /usr/local/lib/boost/boost/archive/basic_binary_iprimitive.hpp:163:
 warning: comparison between signed and unsigned integer expressions
 /usr/local/lib/boost/boost/archive/basic_binary_iprimitive.hpp: In member
 function void boost::archive::basic_binary_iprimitive<Archive, Elem,
 Tr>::load_binary(void*, size_t) [with Archive =
 boost::archive::binary_iarchive, Elem = char, Tr =
 std::char_traits<char>]:
 /usr/local/lib/boost/libs/serialization/src/binary_iarchive.cpp:38:
 instantiated from here
 /usr/local/lib/boost/boost/archive/basic_binary_iprimitive.hpp:163:
 warning: comparison between signed and unsigned integer expressions
 }}}

 GCC Compiler version 4.1.2 .

 I suspect the problem has something to do with the GNU GCC's definition of
 'streamsize' as:

 {{{
   /// Integral type for I/O operation counts and buffer sizes.
   typedef ptrdiff_t streamsize; // Signed integral type
 }}}
 -- from bits/postypes.h

 The warning is caused by the following code:

 {{{
     std::streamsize s = count / sizeof(Elem);
     std::streamsize scount = m_sb.sgetn(
         static_cast<Elem *>(address),
         s
     );
     if(scount != static_cast<std::size_t>(s))
         boost::throw_exception(
             archive_exception(archive_exception::stream_error)
         );
 }}}

 Changing 'std::size_t' into 'std::streamsize' seems to resolve the
 problem.

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1229>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:56 UTC