From f5fa5b9fe3b02f26b38612f96cba19aceccbc2a3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 19 Sep 2020 11:44:39 -0700 Subject: [PATCH] [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 --- compiler-rt/lib/scudo/standalone/tests/checksum_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 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. -- 2.34.1