diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp index 6b6538735beb0..61c9bbb03f7f2 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp @@ -680,7 +680,8 @@ ThreadState *cur_thread() { // significant bit of TLS_SLOT_SANITIZER to 1. Scudo allocator uses this bit // as a flag to disable memory initialization. This is a workaround to get the // correct ThreadState pointer. - reinterpret_cast(addr & ~1ULL); + uptr addr = reinterpret_cast(thr); + return reinterpret_cast(addr & ~1ULL); } void set_cur_thread(ThreadState *thr) {