fix wrong mask in alignment calculation
authorJacob Lifshay <programmerjake@gmail.com>
Wed, 20 Sep 2017 05:03:23 +0000 (22:03 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Wed, 20 Sep 2017 05:03:23 +0000 (22:03 -0700)
src/util/memory.h

index 45127e22de00cb432e0b06970e3b4e89ff14fc24..67479cb7765a71bc0fa383721e50a6b5e8fd399b 100644 (file)
@@ -66,7 +66,7 @@ struct Aligned_memory_allocator_base<Alignment, true>
         Base_pointer base = new unsigned char[size];
         auto alignment_start = reinterpret_cast<std::uintptr_t>(base + sizeof(Base_pointer));
         auto retval =
-            reinterpret_cast<unsigned char *>((alignment_start + Alignment - 1) & (Alignment - 1));
+            reinterpret_cast<unsigned char *>((alignment_start + Alignment - 1) & ~(Alignment - 1));
         auto base_location = reinterpret_cast<Base_pointer *>(retval) - 1;
         *base_location = base;
         return retval;