[compiler-rt] f5fa5b9 - [scudo/standalone] Fix undefined behavior in checksum test
Roland McGrath via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 19 12:28:11 PDT 2020
Author: Roland McGrath
Date: 2020-09-19T12:28:00-07:00
New Revision: f5fa5b9fe3b02f26b38612f96cba19aceccbc2a3
URL: https://github.com/llvm/llvm-project/commit/f5fa5b9fe3b02f26b38612f96cba19aceccbc2a3
DIFF: https://github.com/llvm/llvm-project/commit/f5fa5b9fe3b02f26b38612f96cba19aceccbc2a3.diff
LOG: [scudo/standalone] Fix undefined behavior in checksum test
1U has type unsigned int, and << of 32 or more is undefined behavior.
Use the proper type in the lhs of the shift.
Reviewed By: cryptoad
Differential Revision: https://reviews.llvm.org/D87973
Added:
Modified:
compiler-rt/lib/scudo/standalone/tests/checksum_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/tests/checksum_test.cpp b/compiler-rt/lib/scudo/standalone/tests/checksum_test.cpp
index 361d33c7e464..781f990ecb77 100644
--- a/compiler-rt/lib/scudo/standalone/tests/checksum_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/checksum_test.cpp
@@ -41,10 +41,10 @@ template <ComputeChecksum F> void verifyChecksumFunctionBitFlip() {
scudo::u8 IdenticalChecksums = 0;
for (scudo::uptr I = 0; I < ArraySize; I++) {
for (scudo::uptr J = 0; J < SCUDO_WORDSIZE; J++) {
- Array[I] ^= 1U << J;
+ Array[I] ^= scudo::uptr{1} << J;
if (F(Seed, Array, ArraySize) == Reference)
IdenticalChecksums++;
- Array[I] ^= 1U << J;
+ Array[I] ^= scudo::uptr{1} << J;
}
}
// Allow for a couple of identical checksums over the whole set of flips.
More information about the llvm-commits
mailing list