Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81114 - in trunk/boost/ratio: . detail
From: vicente.botet_at_[hidden]
Date: 2012-10-30 15:55:18


Author: viboes
Date: 2012-10-30 15:55:17 EDT (Tue, 30 Oct 2012)
New Revision: 81114
URL: http://svn.boost.org/trac/boost/changeset/81114

Log:
Ratio: silence warning shift count negative or too big, undefined behavior
Text files modified:
   trunk/boost/ratio/config.hpp | 6 ++++++
   trunk/boost/ratio/detail/overflow_helpers.hpp | 4 ++--
   2 files changed, 8 insertions(+), 2 deletions(-)

Modified: trunk/boost/ratio/config.hpp
==============================================================================
--- trunk/boost/ratio/config.hpp (original)
+++ trunk/boost/ratio/config.hpp 2012-10-30 15:55:17 EDT (Tue, 30 Oct 2012)
@@ -49,6 +49,12 @@
 #define BOOST_RATIO_INTMAX_C(a) a##LL
 #endif
 
+#ifdef UINTMAX_C
+#define BOOST_RATIO_UINTMAX_C(a) UINTMAX_C(a)
+#else
+#define BOOST_RATIO_UINTMAX_C(a) a##ULL
+#endif
+
 #define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFELL)
 
 

Modified: trunk/boost/ratio/detail/overflow_helpers.hpp
==============================================================================
--- trunk/boost/ratio/detail/overflow_helpers.hpp (original)
+++ trunk/boost/ratio/detail/overflow_helpers.hpp 2012-10-30 15:55:17 EDT (Tue, 30 Oct 2012)
@@ -133,7 +133,7 @@
   class br_mul
   {
       static const boost::intmax_t nan =
- (BOOST_RATIO_INTMAX_C(1) << (sizeof(boost::intmax_t) * CHAR_BIT - 1));
+ boost::intmax_t(BOOST_RATIO_UINTMAX_C(1) << (sizeof(boost::intmax_t) * CHAR_BIT - 1));
       static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
       static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
 
@@ -172,7 +172,7 @@
   template <boost::intmax_t X, boost::intmax_t Y>
   class br_div
   {
- static const boost::intmax_t nan = (1LL << (sizeof(boost::intmax_t) * CHAR_BIT - 1));
+ static const boost::intmax_t nan = boost::intmax_t(BOOST_RATIO_UINTMAX_C(1) << (sizeof(boost::intmax_t) * CHAR_BIT - 1));
       static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
       static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
 


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