dim created this revision. dim added reviewers: mclow.lists, EricWF. dim added subscribers: emaste, cfe-commits.
When I compile <bitset> is compiled with warnings enabled, I get the following error (which is interesting in itself, it should only be a warning): /usr/include/c++/v1/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} ^~~ /usr/include/c++/v1/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) {} ^ /home/dim/src/llvm/trunk/include/llvm/IR/Attributes.h:455:9: note: in instantiation of member function 'std::__1::bitset<53>::bitset' requested here : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0), ^ /usr/include/c++/v1/bitset:265:16: note: insert an explicit cast to silence this issue : __first_{__v, __v >> __bits_per_word} ^~~ Note that this is on i386, so this uses the `#elif` part of the `__bitset` constructor: __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_CONSTEXPR #if __SIZEOF_SIZE_T__ == 8 : __first_{__v} #elif __SIZEOF_SIZE_T__ == 4 : __first_{__v, __v >> __bits_per_word} #else #error This constructor has not been ported to this platform #endif #endif Indeed, `__first_` has type `__storage_type`, which is 32 bits on this platform, so I think an explicit static_cast is required here. https://reviews.llvm.org/D23960 Files: include/bitset Index: include/bitset =================================================================== --- include/bitset +++ include/bitset @@ -259,7 +259,7 @@ #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
Index: include/bitset =================================================================== --- include/bitset +++ include/bitset @@ -259,7 +259,7 @@ #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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits