From 2f23dc9127e6c0ef392f163cbaa58afcb7b61a09 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 8 Sep 2022 13:49:07 -0700 Subject: [PATCH] [AST/Interp] Fix left shift overflow bug in D64146 Noticed by Dmitri Gribenko --- clang/lib/AST/Interp/Descriptor.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/Interp/Descriptor.cpp b/clang/lib/AST/Interp/Descriptor.cpp index 2098ae7..34240ed 100644 --- a/clang/lib/AST/Interp/Descriptor.cpp +++ b/clang/lib/AST/Interp/Descriptor.cpp @@ -269,7 +269,7 @@ InitMap::T *InitMap::data() { bool InitMap::initialize(unsigned I) { unsigned Bucket = I / PER_FIELD; - unsigned Mask = 1ull << static_cast(I % PER_FIELD); + T Mask = T(1) << (I % PER_FIELD); if (!(data()[Bucket] & Mask)) { data()[Bucket] |= Mask; UninitFields -= 1; @@ -279,8 +279,7 @@ bool InitMap::initialize(unsigned I) { bool InitMap::isInitialized(unsigned I) { unsigned Bucket = I / PER_FIELD; - unsigned Mask = 1ull << static_cast(I % PER_FIELD); - return data()[Bucket] & Mask; + return data()[Bucket] & (T(1) << (I % PER_FIELD)); } InitMap *InitMap::allocate(unsigned N) { -- 2.7.4