|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77623 - in sandbox/big_number: boost/multiprecision boost/multiprecision/detail libs/multiprecision/test
From: john_at_[hidden]
Date: 2012-03-29 05:12:10
Author: johnmaddock
Date: 2012-03-29 05:12:08 EDT (Thu, 29 Mar 2012)
New Revision: 77623
URL: http://svn.boost.org/trac/boost/changeset/77623
Log:
Squash some MSVC level 4 compiler warnings.
Text files modified:
sandbox/big_number/boost/multiprecision/cpp_int.hpp | 23 +++++++++++++++++------
sandbox/big_number/boost/multiprecision/detail/default_ops.hpp | 14 +++++++++-----
sandbox/big_number/boost/multiprecision/detail/mp_number_base.hpp | 4 ++++
sandbox/big_number/boost/multiprecision/gmp.hpp | 12 +++++++++++-
sandbox/big_number/boost/multiprecision/mp_number.hpp | 20 +++++++++++++++-----
sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp | 17 +++++++++++++----
6 files changed, 69 insertions(+), 21 deletions(-)
Modified: sandbox/big_number/boost/multiprecision/cpp_int.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/cpp_int.hpp (original)
+++ sandbox/big_number/boost/multiprecision/cpp_int.hpp 2012-03-29 05:12:08 EDT (Thu, 29 Mar 2012)
@@ -21,6 +21,12 @@
namespace multiprecision{
namespace backends{
+#ifdef BOOST_MSVC
+// warning C4127: conditional expression is constant
+#pragma warning(push)
+#pragma warning(disable:4127)
+#endif
+
template <unsigned MinBits = 0, bool Signed = true, class Allocator = std::allocator<limb_type> >
struct cpp_int_backend;
@@ -212,7 +218,7 @@
}
void resize(unsigned new_size)
{
- m_limbs = (std::min)(new_size, internal_limb_count);
+ m_limbs = static_cast<boost::uint16_t>((std::min)(new_size, internal_limb_count));
}
void normalize()
{
@@ -604,7 +610,7 @@
{
this->do_swap(o);
}
- std::string str(std::streamsize digits, std::ios_base::fmtflags f)const
+ std::string str(std::streamsize /*digits*/, std::ios_base::fmtflags f)const
{
int base = 10;
if((f & std::ios_base::oct) == std::ios_base::oct)
@@ -626,7 +632,7 @@
int pos = result.size() - 1;
for(unsigned i = 0; i < Bits / shift; ++i)
{
- char c = '0' + (t.limbs()[0] & mask);
+ char c = '0' + static_cast<char>(t.limbs()[0] & mask);
if(c > '9')
c += 'A' - '9' - 1;
result[pos--] = c;
@@ -635,7 +641,7 @@
if(Bits % shift)
{
mask = static_cast<limb_type>((1u << (Bits % shift)) - 1);
- char c = '0' + (t.limbs()[0] & mask);
+ char c = '0' + static_cast<char>(t.limbs()[0] & mask);
if(c > '9')
c += 'A' - '9';
result[pos] = c;
@@ -1268,7 +1274,8 @@
if(result)
result->resize(1 + r_order - y_order);
typename cpp_int_backend<MinBits, Signed, Allocator>::const_limb_pointer prem = r.limbs();
- typename cpp_int_backend<MinBits, Signed, Allocator>::limb_pointer pr;
+ // This is initialised just to keep the compiler from emitting useless warnings later on:
+ typename cpp_int_backend<MinBits, Signed, Allocator>::limb_pointer pr = typename cpp_int_backend<MinBits, Signed, Allocator>::limb_pointer();
if(result)
{
pr = result->limbs();
@@ -1494,7 +1501,8 @@
return;
}
- typename cpp_int_backend<MinBits, Signed, Allocator>::limb_pointer pres;
+ // This is initialised just to keep the compiler from emitting useless warnings later on:
+ typename cpp_int_backend<MinBits, Signed, Allocator>::limb_pointer pres = typename cpp_int_backend<MinBits, Signed, Allocator>::limb_pointer();
if(result)
{
result->resize(r_order + 1);
@@ -2282,6 +2290,9 @@
typedef mp_number<cpp_int_backend<512, true, void>, false> mp_int512_t;
typedef mp_number<cpp_int_backend<1024, true, void>, false> mp_int1024_t;
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
}} // namespaces
Modified: sandbox/big_number/boost/multiprecision/detail/default_ops.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/default_ops.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/default_ops.hpp 2012-03-29 05:12:08 EDT (Thu, 29 Mar 2012)
@@ -26,6 +26,11 @@
namespace boost{ namespace multiprecision{ namespace default_ops{
+#ifdef BOOST_MSVC
+// warning C4127: conditional expression is constant
+#pragma warning(push)
+#pragma warning(disable:4127)
+#endif
//
// Default versions of mixed arithmetic, these just construct a temporary
// from the arithmetic value and then do the arithmetic on that:
@@ -108,7 +113,7 @@
inline bool is_same_object(const T& u, const T&v)
{ return &u == &v; }
template <class T, class U>
-inline bool is_same_object(const T& u, const U&v)
+inline bool is_same_object(const T&, const U&)
{ return false; }
//
@@ -528,7 +533,6 @@
inline bool eval_bit_test(const T& val, unsigned index)
{
typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
- unsigned result = 0;
T mask, t;
mask = ui_type(1);
eval_left_shift(mask, index);
@@ -540,7 +544,6 @@
inline void eval_bit_set(T& val, unsigned index)
{
typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
- unsigned result = 0;
T mask;
mask = ui_type(1);
eval_left_shift(mask, index);
@@ -551,7 +554,6 @@
inline void eval_bit_flip(T& val, unsigned index)
{
typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
- unsigned result = 0;
T mask;
mask = ui_type(1);
eval_left_shift(mask, index);
@@ -562,7 +564,6 @@
inline void eval_bit_unset(T& val, unsigned index)
{
typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
- unsigned result = 0;
T mask, t;
mask = ui_type(1);
eval_left_shift(mask, index);
@@ -1285,6 +1286,9 @@
return boost::math::sinhc_pi(x);
}
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
} // namespace math
} // namespace boost
Modified: sandbox/big_number/boost/multiprecision/detail/mp_number_base.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/mp_number_base.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/mp_number_base.hpp 2012-03-29 05:12:08 EDT (Thu, 29 Mar 2012)
@@ -249,6 +249,7 @@
private:
typename mp_exp_storage<Arg1>::type arg;
+ mp_exp& operator=(const mp_exp&);
};
template<class Arg1>
@@ -271,6 +272,7 @@
private:
typename mp_exp_storage<Arg1>::type arg;
+ mp_exp& operator=(const mp_exp&);
};
template <class tag, class Arg1, class Arg2>
@@ -303,6 +305,7 @@
private:
typename mp_exp_storage<Arg1>::type arg1;
typename mp_exp_storage<Arg2>::type arg2;
+ mp_exp& operator=(const mp_exp&);
};
template <class tag, class Arg1, class Arg2, class Arg3>
@@ -344,6 +347,7 @@
typename mp_exp_storage<Arg1>::type arg1;
typename mp_exp_storage<Arg2>::type arg2;
typename mp_exp_storage<Arg3>::type arg3;
+ mp_exp& operator=(const mp_exp&);
};
template <class T>
Modified: sandbox/big_number/boost/multiprecision/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/gmp.hpp (original)
+++ sandbox/big_number/boost/multiprecision/gmp.hpp 2012-03-29 05:12:08 EDT (Thu, 29 Mar 2012)
@@ -21,6 +21,12 @@
namespace multiprecision{
namespace backends{
+#ifdef BOOST_MSVC
+// warning C4127: conditional expression is constant
+#pragma warning(push)
+#pragma warning(disable:4127)
+#endif
+
template <unsigned digits10>
struct gmp_float;
@@ -1560,7 +1566,7 @@
{
mpq_swap(m_data, o.m_data);
}
- std::string str(std::streamsize /*digits*/, std::ios_base::fmtflags f)const
+ std::string str(std::streamsize /*digits*/, std::ios_base::fmtflags /*f*/)const
{
// TODO make a better job of this including handling of f!!
void *(*alloc_func_ptr) (size_t);
@@ -2053,6 +2059,10 @@
BOOST_STATIC_CONSTEXPR float_round_style round_style = round_toward_zero;
};
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
} // namespace std
#endif
Modified: sandbox/big_number/boost/multiprecision/mp_number.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mp_number.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mp_number.hpp 2012-03-29 05:12:08 EDT (Thu, 29 Mar 2012)
@@ -23,6 +23,12 @@
namespace boost{ namespace multiprecision{
+#ifdef BOOST_MSVC
+// warning C4127: conditional expression is constant
+#pragma warning(push)
+#pragma warning(disable:4127)
+#endif
+
template <class Backend, bool ExpressionTemplates>
class mp_number
{
@@ -32,7 +38,7 @@
mp_number(){}
mp_number(const mp_number& e) : m_backend(e.m_backend){}
template <class V>
- mp_number(V v, typename enable_if<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > >::type* dummy1 = 0)
+ mp_number(V v, typename enable_if<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > >::type* = 0)
{
m_backend = canonical_value(v);
}
@@ -71,7 +77,7 @@
}
template <class V>
- mp_number(V v, typename enable_if<mpl::and_<is_convertible<V, Backend>, mpl::not_<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > > > >::type* dummy1 = 0)
+ mp_number(V v, typename enable_if<mpl::and_<is_convertible<V, Backend>, mpl::not_<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > > > >::type* = 0)
: m_backend(v){}
template <class tag, class Arg1, class Arg2, class Arg3>
@@ -576,7 +582,7 @@
BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a value greater than std::numeric_limits<std::size_t>::max()."));
}
template <class V>
- void check_shift_range(V val, const mpl::false_&, const mpl::false_&){}
+ void check_shift_range(V, const mpl::false_&, const mpl::false_&){}
template <class Exp>
void do_assign(const Exp& e, const detail::add_immediates&)
@@ -1443,7 +1449,7 @@
return is_realy_self(e.value());
}
template <class Exp, int v>
- bool is_self(const Exp& e, mpl::int_<v> const&)const
+ bool is_self(const Exp&, mpl::int_<v> const&)const
{
return false;
}
@@ -1454,7 +1460,7 @@
static const Backend& canonical_value(const self_type& v){ return v.m_backend; }
template <class V>
- static typename detail::canonical<V, Backend>::type canonical_value(const V& v){ return v; }
+ static typename detail::canonical<V, Backend>::type canonical_value(const V& v){ return static_cast<typename detail::canonical<V, Backend>::type>(v); }
static typename detail::canonical<std::string, Backend>::type canonical_value(const std::string& v){ return v.c_str(); }
static const Backend& function_arg_value(const self_type& v) { return v.backend(); }
@@ -1716,6 +1722,10 @@
return a.denominator();
}
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
} // namespaces
#endif
Modified: sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp 2012-03-29 05:12:08 EDT (Thu, 29 Mar 2012)
@@ -80,6 +80,11 @@
#endif
+#ifdef BOOST_MSVC
+// warning C4127: conditional expression is constant
+#pragma warning(disable:4127)
+#endif
+
#define BOOST_TEST_THROW(x, EX)\
try { x; BOOST_ERROR("Expected exception not thrown"); } \
catch(const EX&){}\
@@ -413,10 +418,14 @@
BOOST_TEST(bit_test(Real(1) << (i * 17), i * 17));
BOOST_TEST(!bit_test(Real(1) << (i * 17), i * 17 + 1));
BOOST_TEST(!bit_test(Real(1) << (i * 17), i * 17 - 1));
- BOOST_TEST(bit_test(bit_set(Real(0), i * 17), i * 17));
- BOOST_TEST(bit_flip(Real(0), i*17) == Real(1) << i * 17);
- BOOST_TEST(bit_flip(Real(Real(1) << i * 17), i * 17) == 0);
- BOOST_TEST(bit_unset(Real(Real(1) << i * 17), i * 17) == 0);
+ Real zero(0);
+ BOOST_TEST(bit_test(bit_set(zero, i * 17), i * 17));
+ zero = 0;
+ BOOST_TEST(bit_flip(zero, i*17) == Real(1) << i * 17);
+ zero = Real(1) << i * 17;
+ BOOST_TEST(bit_flip(zero, i * 17) == 0);
+ zero = Real(1) << i * 17;
+ BOOST_TEST(bit_unset(zero, i * 17) == 0);
}
}
}
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