diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-07-29 11:48:38 -0700 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-07-29 11:48:38 -0700 |
commit | 0570594f2c0c9fd241ff76f741d034e1daf106f9 (patch) | |
tree | 54b30889b99971683a29a86acdd762c391bf7dbb | |
parent | 099597406ff022bc29311fd3246d749dc04bd861 (diff) |
Fixed a few compilation warnings triggered by clang
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h | 13 | ||||
-rw-r--r-- | unsupported/test/cxx11_tensor_intdiv.cpp | 8 |
2 files changed, 13 insertions, 8 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h b/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h index b2e570ed1..7cdef6bc5 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h @@ -55,9 +55,14 @@ namespace { } template <typename T> + struct UnsignedTraits { + typedef typename conditional<sizeof(T) == 8, uint64_t, uint32_t>::type type; + }; + + template <typename T> struct DividerTraits { #if defined(__SIZEOF_INT128__) && !defined(__CUDACC__) - typedef typename conditional<sizeof(T) == 8, uint64_t, uint32_t>::type type; + typedef typename UnsignedTraits<T>::type type; static const int N = sizeof(T) * 8; #else typedef uint32_t type; @@ -125,14 +130,14 @@ struct TensorIntDivisor { // the __uint128_t type. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorIntDivisor(const T divider) { const int N = DividerTraits<T>::N; - eigen_assert(divider < NumTraits<UnsignedType>::highest()/2); + eigen_assert(static_cast<typename UnsignedTraits<T>::type>(divider) < NumTraits<UnsignedType>::highest()/2); eigen_assert(divider > 0); // fast ln2 const int leading_zeros = count_leading_zeros(static_cast<UnsignedType>(divider)); int log_div = N - leading_zeros; // if divider is a power of two then log_div is 1 more than it should be. - if ((1ull << (log_div-1)) == divider) + if ((static_cast<typename UnsignedTraits<T>::type>(1) << (log_div-1)) == static_cast<typename UnsignedTraits<T>::type>(divider)) log_div--; multiplier = DividerHelper<N, T>::computeMultiplier(log_div, divider); @@ -143,7 +148,7 @@ struct TensorIntDivisor { // Must have 0 <= numerator. On platforms that dont support the __uint128_t // type numerator should also be less than 2^32-1. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T divide(const T numerator) const { - eigen_assert(numerator < NumTraits<UnsignedType>::highest()/2); + eigen_assert(static_cast<typename UnsignedTraits<T>::type>(numerator) < NumTraits<UnsignedType>::highest()/2); eigen_assert(numerator >= 0); UnsignedType t1 = muluh(multiplier, numerator); diff --git a/unsupported/test/cxx11_tensor_intdiv.cpp b/unsupported/test/cxx11_tensor_intdiv.cpp index b005238bd..343b37dbd 100644 --- a/unsupported/test/cxx11_tensor_intdiv.cpp +++ b/unsupported/test/cxx11_tensor_intdiv.cpp @@ -69,13 +69,13 @@ void test_unsigned_64bit() void test_powers_32bit() { for (int expon = 1; expon < 31; expon++) { - int32_t div = (1ull << expon); + int32_t div = (1 << expon); for (int num_expon = 0; num_expon < 32; num_expon++) { - int32_t start_num = (1ull << num_expon) - 100; - int32_t end_num = (1ull << num_expon) + 100; + int32_t start_num = (1 << num_expon) - 100; + int32_t end_num = (1 << num_expon) + 100; if (start_num < 0) start_num = 0; - for (int64_t num = start_num; num < end_num; num++) { + for (int32_t num = start_num; num < end_num; num++) { Eigen::internal::TensorIntDivisor<int32_t> divider = Eigen::internal::TensorIntDivisor<int32_t>(div); int32_t result = num/div; |