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)
43
43
},
44
44
[&] {
45
45
// 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
+
46
53
muhash /= muhash;
54
+
55
+ #if defined(__clang__)
56
+ # pragma clang diagnostic pop
57
+ #endif
58
+
47
59
muhash.Finalize (out);
48
60
out2 = uint256S (initial_state_hash);
49
61
},
Original file line number Diff line number Diff line change @@ -267,6 +267,22 @@ BOOST_AUTO_TEST_CASE( conversion )
267
267
268
268
BOOST_AUTO_TEST_CASE ( operator_with_self )
269
269
{
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
270
286
arith_uint256 v = UintToArith256 (uint256S (" 02" ));
271
287
v *= v;
272
288
BOOST_CHECK (v == UintToArith256 (uint256S (" 04" )));
@@ -276,6 +292,9 @@ BOOST_AUTO_TEST_CASE( operator_with_self )
276
292
BOOST_CHECK (v == UintToArith256 (uint256S (" 02" )));
277
293
v -= v;
278
294
BOOST_CHECK (v == UintToArith256 (uint256S (" 0" )));
295
+ #if defined(__clang__)
296
+ # pragma clang diagnostic pop
297
+ #endif
279
298
}
280
299
281
300
BOOST_AUTO_TEST_CASE (parse)
You can’t perform that action at this time.
0 commit comments