From 0c8a1d615a300c61c0864c4033c19f4c62895c31 Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Wed, 24 May 2017 06:32:39 -0700 Subject: [PATCH] fix as described in PR #53. fixes warnings Seen with all versions of msvc from (at least) 9.0 up to 14.1. Signed-off-by: Daniela Engert dani@ngrt.de fixed pr #53, #52, #50, #49, #34, #29, #23, #25, #20, #14, #7 --- CMake/CMakeLists.txt | 2 +- doc/archives.html | 2 +- doc/special.html | 4 +- include/boost/archive/detail/iserializer.hpp | 2 +- .../archive/impl/text_wiarchive_impl.ipp | 2 +- include/boost/archive/iterators/escape.hpp | 3 +- .../archive/iterators/istream_iterator.hpp | 6 +-- .../archive/iterators/transform_width.hpp | 1 + include/boost/serialization/binary_object.hpp | 4 +- .../serialization/collections_load_imp.hpp | 2 +- include/boost/serialization/factory.hpp | 45 ++++++++++--------- src/basic_iarchive.cpp | 2 +- src/basic_xml_grammar.ipp | 3 +- util/test.jam | 1 + 14 files changed, 41 insertions(+), 38 deletions(-) diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt index ddd016dd..02fe5676 100644 --- a/CMake/CMakeLists.txt +++ b/CMake/CMakeLists.txt @@ -26,7 +26,7 @@ add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) add_definitions( -ftemplate-depth=300 ) # we use gcc to test for C++03 compatibility - add_definitions( std=c++03 ) + add_definitions( -std=c++03 ) message(STATUS "compiler is g++ c++03") set(COMPILER_SUPPORTS_CXX11 FALSE) elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" ) diff --git a/doc/archives.html b/doc/archives.html index bcae0d4b..0f16227a 100644 --- a/doc/archives.html +++ b/doc/archives.html @@ -292,7 +292,7 @@ included in the code module containing the serialization code. -All of these archives implement the same inteface. Hence, it should suffice to describe only one +All of these archives implement the same interface. Hence, it should suffice to describe only one of them in detail. For this purpose we will use the text archive. diff --git a/doc/special.html b/doc/special.html index 8984710c..27295011 100644 --- a/doc/special.html +++ b/doc/special.html @@ -568,10 +568,10 @@ void myclass::serialize(Archive & ar, const unsigned int version){ ... } -BOOST_EXPORT_CLASS_IMPLEMENT(my_class) +BOOST_CLASS_EXPORT_IMPLEMENT(my_class) #include <boost/archive/text_oarchive> -#include <boost/archive/text_iarchive< +#include <boost/archive/text_iarchive> template myclass::serialize(boost::archive::text_oarchive & ar, const unsigned int version); template myclass::serialize(boost::archive::text_iarchive & ar, const unsigned int version); ... // repeat for each archive class to be used. diff --git a/include/boost/archive/detail/iserializer.hpp b/include/boost/archive/detail/iserializer.hpp index 6e02eec7..193e98a8 100644 --- a/include/boost/archive/detail/iserializer.hpp +++ b/include/boost/archive/detail/iserializer.hpp @@ -605,7 +605,7 @@ template inline void load(Archive & ar, T &t){ // if this assertion trips. It means we're trying to load a // const object with a compiler that doesn't have correct - // funtion template ordering. On other compilers, this is + // function template ordering. On other compilers, this is // handled below. detail::check_const_loading< T >(); typedef diff --git a/include/boost/archive/impl/text_wiarchive_impl.ipp b/include/boost/archive/impl/text_wiarchive_impl.ipp index 12af2b9f..e85625ac 100644 --- a/include/boost/archive/impl/text_wiarchive_impl.ipp +++ b/include/boost/archive/impl/text_wiarchive_impl.ipp @@ -56,7 +56,7 @@ text_wiarchive_impl::load(std::string &s) s.resize(0); s.reserve(size); while(size-- > 0){ - int x = is.narrow(is.get(), '\0'); + char x = is.narrow(is.get(), '\0'); s += x; } } diff --git a/include/boost/archive/iterators/escape.hpp b/include/boost/archive/iterators/escape.hpp index a1fee914..c8ec903a 100644 --- a/include/boost/archive/iterators/escape.hpp +++ b/include/boost/archive/iterators/escape.hpp @@ -102,7 +102,8 @@ public: super_t(base), m_bnext(NULL), m_bend(NULL), - m_full(false) + m_full(false), + m_current_value(NULL) { } }; diff --git a/include/boost/archive/iterators/istream_iterator.hpp b/include/boost/archive/iterators/istream_iterator.hpp index 9a1d555c..a187f605 100644 --- a/include/boost/archive/iterators/istream_iterator.hpp +++ b/include/boost/archive/iterators/istream_iterator.hpp @@ -56,7 +56,7 @@ class istream_iterator : //Access the value referred to Elem dereference() const { - return m_istream->peek(); + return static_cast(m_istream->peek()); } void increment(){ @@ -75,14 +75,14 @@ public: } istream_iterator() : - m_istream(NULL) + m_istream(NULL), + m_current_value(NULL) {} istream_iterator(const istream_iterator & rhs) : m_istream(rhs.m_istream), m_current_value(rhs.m_current_value) {} - }; } // namespace iterators diff --git a/include/boost/archive/iterators/transform_width.hpp b/include/boost/archive/iterators/transform_width.hpp index d042560e..09c050a9 100644 --- a/include/boost/archive/iterators/transform_width.hpp +++ b/include/boost/archive/iterators/transform_width.hpp @@ -111,6 +111,7 @@ public: transform_width(T start) : super_t(Base(static_cast< T >(start))), m_buffer_out_full(false), + m_buffer_out(0), // To disable GCC warning, but not truly necessary //(m_buffer_in will be initialized later before being //used because m_remaining_bits == 0) diff --git a/include/boost/serialization/binary_object.hpp b/include/boost/serialization/binary_object.hpp index 23c734be..5c9038e5 100644 --- a/include/boost/serialization/binary_object.hpp +++ b/include/boost/serialization/binary_object.hpp @@ -55,7 +55,7 @@ struct binary_object : m_size = rhs.m_size; return *this; } - binary_object(/* const */ void * const t, std::size_t size) : + binary_object(const void * const t, std::size_t size) : m_t(t), m_size(size) {} @@ -69,7 +69,7 @@ struct binary_object : // wrappers follow the naming convention make_xxxxx inline const binary_object -make_binary_object(/* const */ void * t, std::size_t size){ +make_binary_object(const void * t, std::size_t size){ return binary_object(t, size); } diff --git a/include/boost/serialization/collections_load_imp.hpp b/include/boost/serialization/collections_load_imp.hpp index c3b165a8..e042c0c1 100644 --- a/include/boost/serialization/collections_load_imp.hpp +++ b/include/boost/serialization/collections_load_imp.hpp @@ -64,7 +64,7 @@ collection_load_impl( Archive & ar, T & t, collection_size_type count, - item_version_type + item_version_type /*item_version*/ ){ t.resize(count); typename T::iterator hint; diff --git a/include/boost/serialization/factory.hpp b/include/boost/serialization/factory.hpp index db5b1a92..2db7e7e3 100644 --- a/include/boost/serialization/factory.hpp +++ b/include/boost/serialization/factory.hpp @@ -48,32 +48,33 @@ namespace boost { \ namespace serialization { \ template<> \ T * factory(std::va_list ap){ \ - BOOST_PP_IF(BOOST_PP_GREATER(N,0) \ - ,A0 a0 = va_arg(ap, A0); \ - ,BOOST_PP_IF(BOOST_PP_GREATER(N,1) \ - ,A1 a1 = va_arg(ap, A1); \ - ,BOOST_PP_IF(BOOST_PP_GREATER(N,2) \ - ,A2 a2 = va_arg(ap, A2); \ - ,BOOST_PP_IF(BOOST_PP_GREATER(N,3) \ - ,A3 a3 = va_arg(ap, A3); \ - ,BOOST_PP_EMPTY() \ - )))) \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 0) \ + , A0 a0 = va_arg(ap, A0);, BOOST_PP_EMPTY()) \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 1) \ + , A1 a1 = va_arg(ap, A1);, BOOST_PP_EMPTY()) \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 2) \ + , A2 a2 = va_arg(ap, A2);, BOOST_PP_EMPTY()) \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 3) \ + , A3 a3 = va_arg(ap, A3);, BOOST_PP_EMPTY()) \ return new T( \ - BOOST_PP_IF(BOOST_PP_GREATER(N,0) \ - ,a0 \ - ,BOOST_PP_IF(BOOST_PP_GREATER(N,1) \ - ,a1 \ - ,BOOST_PP_IF(BOOST_PP_GREATER(N,2) \ - ,a2 \ - ,BOOST_PP_IF(BOOST_PP_GREATER(N,3) \ - ,a3 \ - ,BOOST_PP_EMPTY() \ - )))) \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 0) \ + , a0, BOOST_PP_EMPTY()) \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 1)) \ + , BOOST_PP_COMMA, BOOST_PP_EMPTY)() \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 1) \ + , a1, BOOST_PP_EMPTY()) \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 2)) \ + , BOOST_PP_COMMA, BOOST_PP_EMPTY)() \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 2) \ + , a2, BOOST_PP_EMPTY()) \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 3)) \ + , BOOST_PP_COMMA, BOOST_PP_EMPTY)() \ + BOOST_PP_IF(BOOST_PP_GREATER(N, 3) \ + , a3, BOOST_PP_EMPTY()) \ ); \ } \ } \ -} \ -/**/ +} /**/ #define BOOST_SERIALIZATION_FACTORY_4(T, A0, A1, A2, A3) \ BOOST_SERIALIZATION_FACTORY(4, T, A0, A1, A2, A3) diff --git a/src/basic_iarchive.cpp b/src/basic_iarchive.cpp index 841fefdd..cdf71b07 100644 --- a/src/basic_iarchive.cpp +++ b/src/basic_iarchive.cpp @@ -487,7 +487,7 @@ basic_iarchive_impl::load_pointer( m_pending.version = co.file_version; // predict next object id to be created - const unsigned int ui = object_id_vector.size(); + const size_t ui = object_id_vector.size(); serialization::state_saver w_end(m_moveable_objects.end); diff --git a/src/basic_xml_grammar.ipp b/src/basic_xml_grammar.ipp index d0536f40..f028f8fc 100644 --- a/src/basic_xml_grammar.ipp +++ b/src/basic_xml_grammar.ipp @@ -145,8 +145,7 @@ template struct append_char { String & contents; void operator()(const unsigned int char_value) const { - const typename String::value_type z = char_value; - contents += z; + contents += static_cast(char_value); } append_char(String & contents_) : contents(contents_) diff --git a/util/test.jam b/util/test.jam index 127eaff7..1a3bf388 100644 --- a/util/test.jam +++ b/util/test.jam @@ -49,6 +49,7 @@ rule run-template ( test-name : sources * : requirements * ) { clang:debug:"-fsanitize=memory" # toolset optimizations gcc:"-ftemplate-depth-255" + qcc:"-ftemplate-depth-255" clang:"-ftemplate-depth-255" darwin:"-ftemplate-depth-255" msvc:"-Gy"