File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,19 @@ FUZZ_TARGET(muhash)
4343 },
4444 [&] {
4545 // Test that dividing a MuHash by itself brings it back to it's initial state
46+
47+ // See note about clang + self-assignment in test/uint256_tests.cpp
48+ #if defined(__clang__)
49+ # pragma clang diagnostic push
50+ # pragma clang diagnostic ignored "-Wself-assign-overloaded"
51+ #endif
52+
4653 muhash /= muhash;
54+
55+ #if defined(__clang__)
56+ # pragma clang diagnostic pop
57+ #endif
58+
4759 muhash.Finalize (out);
4860 out2 = uint256S (initial_state_hash);
4961 },
Original file line number Diff line number Diff line change @@ -267,6 +267,22 @@ BOOST_AUTO_TEST_CASE( conversion )
267267
268268BOOST_AUTO_TEST_CASE ( operator_with_self )
269269{
270+
271+ /* Clang 16 and earlier detects v -= v and v /= v as self-assignments
272+ to 0 and 1 respectively.
273+ See: https://github.com/llvm/llvm-project/issues/42469
274+ and the fix in commit c5302325b2a62d77cf13dd16cd5c19141862fed0 .
275+
276+ This makes some sense for arithmetic classes, but could be considered a bug
277+ elsewhere. Disable the warning here so that the code can be tested, but the
278+ warning should remain on as there will likely always be a better way to
279+ express this.
280+ */
281+
282+ #if defined(__clang__)
283+ # pragma clang diagnostic push
284+ # pragma clang diagnostic ignored "-Wself-assign-overloaded"
285+ #endif
270286 arith_uint256 v = UintToArith256 (uint256S (" 02" ));
271287 v *= v;
272288 BOOST_CHECK (v == UintToArith256 (uint256S (" 04" )));
@@ -276,6 +292,9 @@ BOOST_AUTO_TEST_CASE( operator_with_self )
276292 BOOST_CHECK (v == UintToArith256 (uint256S (" 02" )));
277293 v -= v;
278294 BOOST_CHECK (v == UintToArith256 (uint256S (" 0" )));
295+ #if defined(__clang__)
296+ # pragma clang diagnostic pop
297+ #endif
279298}
280299
281300BOOST_AUTO_TEST_CASE (parse)
You can’t perform that action at this time.
0 commit comments