refactor: Revert "disable self-assign warning for tests"
What changed, and why it matters
This commit removes compiler warning suppressions from two test files. It is a code cleanup that reverts an earlier workaround for a Clang compiler warning about self-assignment (like x = x). It does not change any production code, network behavior, or wallet logic, and has no direct security impact on Bitcoin users.
No security action required. Treat as routine test-code refactoring. If reviewing, confirm CI still passes with current Clang versions after removing the warning suppressions.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit reverts a prior change that used #pragma clang diagnostic ignored “-Wself-assign-overloaded” to silence Clang 16 and earlier in unit/fuzz tests for arith_uint256 and MuHash self-assignment operations. The diff only deletes those pragma blocks from src/test/arith_uint256_tests.cpp and src/test/fuzz/muhash.cpp. The actual test logic (v *= v, v /= v, v -= v, muhash /= muhash) remains unchanged. The revert implies the upstream Clang warning issue has been resolved or the project no longer needs the suppression, but the commit itself contains no functional change.
Changed components
src/test/arith_uint256_tests.cppsrc/test/fuzz/muhash.cppInspect captured patch +0 / −29
diff --git a/src/test/arith_uint256_tests.cpp b/src/test/arith_uint256_tests.cpp
index 37a39adb..38ff46cc 100644
--- a/src/test/arith_uint256_tests.cpp
+++ b/src/test/arith_uint256_tests.cpp
@@ -580,20 +580,6 @@ BOOST_AUTO_TEST_CASE(conversion)
BOOST_AUTO_TEST_CASE(operator_with_self)
{
- /* Clang 16 and earlier detects v -= v and v /= v as self-assignments
- to 0 and 1 respectively.
- See: https://github.com/llvm/llvm-project/issues/42469
- and the fix in commit c5302325b2a62d77cf13dd16cd5c19141862fed0 .
-
- This makes some sense for arithmetic classes, but could be considered a bug
- elsewhere. Disable the warning here so that the code can be tested, but the
- warning should remain on as there will likely always be a better way to
- express this.
- */
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wself-assign-overloaded"
-#endif
arith_uint256 v{2};
v *= v;
BOOST_CHECK_EQUAL(v, arith_uint256{4});
@@ -603,9 +589,6 @@ BOOST_AUTO_TEST_CASE(operator_with_self)
BOOST_CHECK_EQUAL(v, arith_uint256{2});
v -= v;
BOOST_CHECK_EQUAL(v, arith_uint256{0});
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/test/fuzz/muhash.cpp b/src/test/fuzz/muhash.cpp
index 922c6ff8..fa0fe49f 100644
--- a/src/test/fuzz/muhash.cpp
+++ b/src/test/fuzz/muhash.cpp
@@ -199,19 +199,7 @@ FUZZ_TARGET(muhash)
},
[&] {
// Test that dividing a MuHash by itself brings it back to its initial state
-
- // See note about clang + self-assignment in test/uint256_tests.cpp
- #if defined(__clang__)
- # pragma clang diagnostic push
- # pragma clang diagnostic ignored "-Wself-assign-overloaded"
- #endif
-
muhash /= muhash;
-
- #if defined(__clang__)
- # pragma clang diagnostic pop
- #endif
-
muhash.Finalize(out);
out2 = initial_state_hash;
},
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.