mclow.lists accepted this revision.
mclow.lists added inline comments.
This revision is now accepted and ready to land.
Comment at: include/__hash_table:140
+return (__n > 1) ? (size_t(1) << (std::numeric_limits::digits -
__clz(__n-1))) : __n;
}
I turned
vsk added inline comments.
Comment at: include/__hash_table:139
{
-return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
+return (__n > 1) ? (size_t(1) << (std::numeric_limits::digits -
__clz(__n-1))) : __n;
}
EricWF wrote:
> Shouldn't this
EricWF added inline comments.
Comment at: include/__hash_table:139
{
-return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
+return (__n > 1) ? (size_t(1) << (std::numeric_limits::digits -
__clz(__n-1))) : __n;
}
Shouldn't this return `__n
vsk updated this revision to Diff 100461.
vsk edited the summary of this revision.
vsk added a comment.
Thanks @EricWF for pointing me to the right place to add a test. I've tried to
follow the style used by the existing tests. PTAL.
https://reviews.llvm.org/D33588
Files:
include/__hash_tabl
EricWF added a comment.
@vsk: I would include your fuzzing test in this patch. Simply put it somewhere
under `test/libcxx/containers/unordered`.
https://reviews.llvm.org/D33588
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.ll
vsk added a comment.
In https://reviews.llvm.org/D33588#765768, @mclow.lists wrote:
> I can reproduce this, but I'd rather figure out why we're calling
> `__next_hash_pow2(0)` or `(1)` before deciding how to fix it.
It looks like we hit the UB while attempting to shrink a hash table during a
mclow.lists added a comment.
I can reproduce this, but I'd rather figure out why we're calling
`__next_hash_pow2(0)` or `(1)` before deciding how to fix it.
https://reviews.llvm.org/D33588
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
htt
vsk created this revision.
There are two sources of undefined behavior in __next_hash_pow2: an
invalid shift (occurs when __n is 0 or 1), and an invalid call to CLZ
(when __n=1).
This patch corrects both issues. It's NFC for all values of __n which do
not trigger UB, and leads to defined results