diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -280,15 +280,18 @@ BOOST_CHECK(R2L.GetHex() == UintToArith256(R2L).GetHex()); } +// Use *& to remove self-assign warning. +#define SELF(x) (*&(x)) + BOOST_AUTO_TEST_CASE(operator_with_self) { arith_uint256 v = UintToArith256(uint256S("02")); - v *= v; + v *= SELF(v); BOOST_CHECK(v == UintToArith256(uint256S("04"))); - v /= v; + v /= SELF(v); BOOST_CHECK(v == UintToArith256(uint256S("01"))); - v += v; + v += SELF(v); BOOST_CHECK(v == UintToArith256(uint256S("02"))); - v -= v; + v -= SELF(v); BOOST_CHECK(v == UintToArith256(uint256S("0"))); }