[PATCH] D33588: Fix two sources of UB in __next_hash_pow2 (from __hash_table)

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 31 17:59:16 PDT 2017


EricWF added inline comments.


================
Comment at: include/__hash_table:139
 {
-    return size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1));
+    return (__n > 1) ? (size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1))) : __n;
 }
----------------
Shouldn't this return  `__n + 1` when `__n <= 1`, or even 2 in both cases?


https://reviews.llvm.org/D33588





More information about the cfe-commits mailing list