[PATCH] D40743: Make rehash(0) work with ubsan's unsigned-integer-overflow.

Marshall Clow via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 07:29:12 PST 2017

mclow.lists accepted this revision.
mclow.lists added inline comments.
This revision is now accepted and ready to land.

Comment at: include/__hash_table:2141
         __n = 2;
     else if (__n & (__n - 1))
         __n = __next_prime(__n);
danalbert wrote:
> With `rehash(0)` this is `0 & (0 - 1)`, which triggers unsigned-integer-overflow.
Grumble, grumble. That's not UB, that's just UBSan whining.
On the other hand, this doesn't appear to change any behavior, and shuts UBSan up.

  rCXX libc++


More information about the cfe-commits mailing list