Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3118: [Serialization] basic_binary_oarchive.hpp - save_override possible loss of data warnings
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-06-02 02:03:04
#3118: [Serialization] basic_binary_oarchive.hpp - save_override possible loss of
data warnings
-----------------------------------+----------------------------------------
Reporter: jflinn_at_[hidden] | Owner: ramey
Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: serialization
Version: Boost 1.39.0 | Severity: Problem
Resolution: | Keywords: Serialization, warning
-----------------------------------+----------------------------------------
Comment(by jflinn_at_[hidden]):
Index: basic_binary_oarchive.hpp
===================================================================
--- basic_binary_oarchive.hpp (revision 53559)
+++ basic_binary_oarchive.hpp (working copy)
@@ -30,6 +30,7 @@
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/collection_size_type.hpp>
+#include <boost/integer_traits.hpp>
namespace boost {
namespace archive {
@@ -69,17 +70,20 @@
void save_override(const version_type & t, int){
// upto 255 versions
// note:t.t resolves borland ambguity
- const unsigned char x = t.t;
+ assert(t.t <= boost::integer_traits<unsigned char>::const_max);
+ const unsigned char x = static_cast<unsigned char>(t.t);
* this->This() << x;
}
void save_override(const class_id_type & t, int){
// upto 32K classes
- const int_least16_t x = t.t;
+ assert(t.t <= boost::integer_traits<int_least16_t>::const_max);
+ const int_least16_t x = static_cast<int_least16_t>(t.t);
* this->This() << x;
}
void save_override(const class_id_reference_type & t, int){
// upto 32K classes
- const int_least16_t x = t.t;
+ assert(t.t <= boost::integer_traits<int_least16_t>::const_max);
+ const int_least16_t x = static_cast<int_least16_t>(t.t);
* this->This() << x;
}
void save_override(const object_id_type & t, int){
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3118#comment:1> 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:50:00 UTC