Make sure the op does not change the sign of the operand
authorAnton Korobeynikov <anton@korobeynikov.info>
Sat, 13 Oct 2012 21:40:58 +0000 (01:40 +0400)
committerJordan DeLong <jdelong@fb.com>
Sat, 19 Jan 2013 00:36:58 +0000 (16:36 -0800)
Summary: .

Test Plan: .

Reviewed By: soren@fb.com

FB internal diff: D660143

Blame Revision:

folly/small_vector.h

index 911f0630fc936439c31bfffbcf96c264aef9b649..cf9caa6e5ac87eb290bcd5d9b77e9e8832df7c54 100644 (file)
@@ -414,7 +414,8 @@ namespace detail {
   }
   template <class T>
   T* pointerFlagClear(T* p) {
-    return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(p) & ~1);
+    return reinterpret_cast<T*>(
+      reinterpret_cast<uintptr_t>(p) & ~uintptr_t(1));
   }
   inline void* shiftPointer(void* p, size_t sizeBytes) {
     return static_cast<char*>(p) + sizeBytes;