summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__hash_table
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-06-03 00:08:32 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-06-03 00:08:32 +0000
commit87af6460342c83374f97fa83d3daa17eea3309cb (patch)
treee0d1ea918391c1a0ba1681fb7ffbb85647c5ceb3 /libcxx/include/__hash_table
parente4e5923ef17c1f9c3511416dedf27fa1758ab32e (diff)
downloadbcm5719-llvm-87af6460342c83374f97fa83d3daa17eea3309cb.tar.gz
bcm5719-llvm-87af6460342c83374f97fa83d3daa17eea3309cb.zip
Fix some undefined behavior in __hash_table. Thanks to vsk for the report and the patch. Reviewed as https://reviews.llvm.org/D33588.
llvm-svn: 304617
Diffstat (limited to 'libcxx/include/__hash_table')
-rw-r--r--libcxx/include/__hash_table2
1 files changed, 1 insertions, 1 deletions
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 79336ff793e..3f430af1283 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -137,7 +137,7 @@ inline _LIBCPP_INLINE_VISIBILITY
size_t
__next_hash_pow2(size_t __n)
{
- return size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1));
+ return __n < 2 ? __n : (size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1)));
}
OpenPOWER on IntegriCloud