Force the overflow in BitVectorCoding::skipTo to be 64-bit
authorChristopher Dykes <cdykes@fb.com>
Wed, 3 Aug 2016 22:09:04 +0000 (15:09 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Wed, 3 Aug 2016 22:23:47 +0000 (15:23 -0700)
Summary: This code was relying on the `- 1` overflowing as a 64-bit value, but MSVC (correctly in my opinion) was overflowing this as a 32-bit value, resulting in a segfault when trying to run the bitvector and eliasfano tests on MSVC.

Reviewed By: yfeldblum

Differential Revision: D3652343

fbshipit-source-id: 38a22abfc0d05ab2f070c450eebfa69af07d26af

folly/experimental/BitVectorCoding.h

index d51b7b968bc5c96010503ac43791c4b5347c84f1..a7f711c24a26de8a2fdae2c2305de320d76a5b3e 100644 (file)
@@ -346,8 +346,8 @@ class BitVectorReader {
 
     if (Encoder::skipQuantum > 0 && v - value_ > Encoder::skipQuantum) {
       size_t q = v / Encoder::skipQuantum;
-      position_ = folly::loadUnaligned<SkipValueType>(
-                      skipPointers_ + (q - 1) * sizeof(SkipValueType)) - 1;
+      position_ = size_t(folly::loadUnaligned<SkipValueType>(
+                      skipPointers_ + (q - 1) * sizeof(SkipValueType))) - 1;
 
       reposition(q * Encoder::skipQuantum);
     }