diff --git a/include/boost/integer/common_factor_rt.hpp b/include/boost/integer/common_factor_rt.hpp index b043e31..341b316 100644 --- a/include/boost/integer/common_factor_rt.hpp +++ b/include/boost/integer/common_factor_rt.hpp @@ -336,9 +336,9 @@ namespace boost { unsigned shifts = 0; - if(!u) + if(u == T(0)) return v; - if(!v) + if(v == T(0)) return u; shifts = constexpr_min(gcd_traits::make_odd(u), gcd_traits::make_odd(v)); @@ -347,9 +347,9 @@ namespace boost { { u %= v; v -= u; - if(!u) + if(u == T(0)) return v << shifts; - if(!v) + if(v == T(0)) return u << shifts; gcd_traits::make_odd(u); gcd_traits::make_odd(v); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 691b703..23b3fe8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -6,6 +6,9 @@ import testing ; project : requirements all gcc:-Wextra ; +obj has_gmpxx : has_gmpxx.cpp ; +explicit has_gmpxx ; + test-suite integer : [ run integer_traits_test.cpp ] @@ -28,5 +31,5 @@ test-suite integer [ compile-fail fail_uint_fast.cpp ] [ compile-fail fail_uint_least.cpp ] [ compile-fail fail_uint_65.cpp ] - [ run common_factor_test.cpp ] + [ run common_factor_test.cpp : : : [ check-target-builds "Checking for gmpxx.h" : BOOST_INTEGER_HAS_GMPXX_H=1 ] ] ; diff --git a/test/common_factor_test.cpp b/test/common_factor_test.cpp index e071afe..0c36984 100644 --- a/test/common_factor_test.cpp +++ b/test/common_factor_test.cpp @@ -31,6 +31,10 @@ #include // for std::numeric_limits #include // for std::basic_ostream +#ifdef BOOST_INTEGER_HAS_GMPXX_H +#include +#endif + namespace { @@ -556,11 +560,11 @@ template void gcd_and_lcm_on_rationals() test(); #ifdef BOOST_HAS_LONG_LONG -# define TEST_SIGNED( test ) \ +# define TEST_SIGNED__( test ) \ TEST_SIGNED_( test ) \ test(); #elif defined(BOOST_HAS_MS_INT64) -# define TEST_SIGNED( test ) \ +# define TEST_SIGNED__( test ) \ TEST_SIGNED_( test ) \ test<__int64>(); #endif @@ -584,6 +588,14 @@ template void gcd_and_lcm_on_rationals() test(); #endif +#ifdef BOOST_INTEGER_HAS_GMPXX_H +# define TEST_SIGNED(test)\ + TEST_SIGNED__(test)\ + test(); +#else +# define TEST_SIGNED(test) TEST_SIGNED__(test) +#endif + int main() { TEST_SIGNED(gcd_int_test) diff --git a/test/has_gmpxx.cpp b/test/has_gmpxx.cpp new file mode 100644 index 0000000..edf62d8 --- /dev/null +++ b/test/has_gmpxx.cpp @@ -0,0 +1,7 @@ +// Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +