From 5f8cb58230f042570d04a5f51991fd2906c58e84 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Fri, 2 Sep 2016 21:02:11 +0000 Subject: [PATCH] Avoid narrowing warnings in __bitset constructor When is compiled with warnings enabled, on a platform where size_t is 4 bytes, it results in errors similar to: bitset:265:16: error: non-constant-expression cannot be narrowed from type 'unsigned long long' to '__storage_type' (aka 'unsigned int') in initializer list [-Wc++11-narrowing] : __first_{__v, __v >> __bits_per_word} ^~~ bitset:676:52: note: in instantiation of member function 'std::__1::__bitset<2, 53>::__bitset' requested here bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} ^ Fix these by casting the initializer list elements to __storage_type. Reviewers: mclow.lists, EricWF Differential Revision: https://reviews.llvm.org/D23960 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@280543 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/bitset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bitset b/include/bitset index 2ad9545f0..edc6c133c 100644 --- a/include/bitset +++ b/include/bitset @@ -259,7 +259,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT #if __SIZEOF_SIZE_T__ == 8 : __first_{__v} #elif __SIZEOF_SIZE_T__ == 4 - : __first_{__v, __v >> __bits_per_word} + : __first_{static_cast<__storage_type>(__v), static_cast<__storage_type>(__v >> __bits_per_word)} #else #error This constructor has not been ported to this platform #endif