Avoid undefined compiler behavior
Technically, shifting a signed value beyond its maximum range is
undefined behavior in C++. A bare integer literal is signed, and
defaults to 'int'. On platforms where 'int' is 32-bits, we
shift outside this range with 1 << 31.
We make our literal an unsigned integer to avoid this.
Test: TreeHugger
Bug: 189541929
Change-Id: Iade1bcd3f86d025dd6e10c26622d10c26e2c8295
diff --git a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
index 68b3a1e..9d33189 100644
--- a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
@@ -511,7 +511,7 @@
for (size_t i = 0; i < kMaxThreads; i++) {
std::thread malloc_thread([&thread_mask, &run, &allocs, i] {
- thread_mask.fetch_or(1 << i);
+ thread_mask.fetch_or(1U << i);
while (!run)
;
for (auto ptr : allocs[i]) {