Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63072 - trunk/boost/archive
From: dgregor_at_[hidden]
Date: 2010-06-17 20:13:29


Author: dgregor
Date: 2010-06-17 20:13:28 EDT (Thu, 17 Jun 2010)
New Revision: 63072
URL: http://svn.boost.org/trac/boost/changeset/63072

Log:
short int might not be large enough to represent all of the values in a wchar_t. Use the integer traits to be sure that we get a type large enough to represent the values of wchar_t
Text files modified:
   trunk/boost/archive/basic_text_iprimitive.hpp | 3 ++-
   trunk/boost/archive/basic_text_oprimitive.hpp | 4 +++-
   2 files changed, 5 insertions(+), 2 deletions(-)

Modified: trunk/boost/archive/basic_text_iprimitive.hpp
==============================================================================
--- trunk/boost/archive/basic_text_iprimitive.hpp (original)
+++ trunk/boost/archive/basic_text_iprimitive.hpp 2010-06-17 20:13:28 EDT (Thu, 17 Jun 2010)
@@ -44,6 +44,7 @@
 #endif
 
 #include <boost/limits.hpp>
+#include <boost/integer.hpp>
 #include <boost/io/ios_state.hpp>
 #include <boost/scoped_ptr.hpp>
 
@@ -116,7 +117,7 @@
     #ifndef BOOST_NO_INTRINSIC_WCHAR_T
     void load(wchar_t & t)
     {
- short int i;
+ typename int_t<sizeof(wchar_t) * CHAR_BIT>::exact i;
         load(i);
         t = i;
     }

Modified: trunk/boost/archive/basic_text_oprimitive.hpp
==============================================================================
--- trunk/boost/archive/basic_text_oprimitive.hpp (original)
+++ trunk/boost/archive/basic_text_oprimitive.hpp 2010-06-17 20:13:28 EDT (Thu, 17 Jun 2010)
@@ -46,6 +46,7 @@
 #endif
 
 #include <boost/limits.hpp>
+#include <boost/integer.hpp>
 #include <boost/io/ios_state.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/serialization/throw_exception.hpp>
@@ -117,7 +118,8 @@
     #ifndef BOOST_NO_INTRINSIC_WCHAR_T
     void save(const wchar_t t)
     {
- save(static_cast<short int>(t));
+ typedef typename int_t<sizeof(wchar_t) * CHAR_BIT>::exact int_type;
+ save(static_cast<int_type>(t));
     }
     #endif
     void save(const float t)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk