Index: include/__bit_reference =================================================================== --- include/__bit_reference +++ include/__bit_reference @@ -163,7 +163,7 @@ { typedef __bit_iterator<_Cp, _IsConst> _It; typedef typename _It::__storage_type __storage_type; - static const unsigned __bits_per_word = _It::__bits_per_word; + static const int __bits_per_word = _It::__bits_per_word; // do first partial word if (__first.__ctz_ != 0) { @@ -199,7 +199,7 @@ { typedef __bit_iterator<_Cp, _IsConst> _It; typedef typename _It::__storage_type __storage_type; - static const unsigned __bits_per_word = _It::__bits_per_word; + static const int __bits_per_word = _It::__bits_per_word; // do first partial word if (__first.__ctz_ != 0) { @@ -251,7 +251,7 @@ typedef __bit_iterator<_Cp, _IsConst> _It; typedef typename _It::__storage_type __storage_type; typedef typename _It::difference_type difference_type; - static const unsigned __bits_per_word = _It::__bits_per_word; + static const int __bits_per_word = _It::__bits_per_word; difference_type __r = 0; // do first partial word if (__first.__ctz_ != 0) @@ -282,7 +282,7 @@ typedef __bit_iterator<_Cp, _IsConst> _It; typedef typename _It::__storage_type __storage_type; typedef typename _It::difference_type difference_type; - static const unsigned __bits_per_word = _It::__bits_per_word; + static const int __bits_per_word = _It::__bits_per_word; difference_type __r = 0; // do first partial word if (__first.__ctz_ != 0) @@ -324,7 +324,7 @@ { typedef __bit_iterator<_Cp, false> _It; typedef typename _It::__storage_type __storage_type; - static const unsigned __bits_per_word = _It::__bits_per_word; + static const int __bits_per_word = _It::__bits_per_word; // do first partial word if (__first.__ctz_ != 0) { @@ -354,7 +354,7 @@ { typedef __bit_iterator<_Cp, false> _It; typedef typename _It::__storage_type __storage_type; - static const unsigned __bits_per_word = _It::__bits_per_word; + static const int __bits_per_word = _It::__bits_per_word; // do first partial word if (__first.__ctz_ != 0) { @@ -412,7 +412,7 @@ typedef __bit_iterator<_Cp, _IsConst> _In; typedef typename _In::difference_type difference_type; typedef typename _In::__storage_type __storage_type; - static const unsigned __bits_per_word = _In::__bits_per_word; + static const int __bits_per_word = _In::__bits_per_word; difference_type __n = __last - __first; if (__n > 0) { @@ -461,7 +461,7 @@ typedef __bit_iterator<_Cp, _IsConst> _In; typedef typename _In::difference_type difference_type; typedef typename _In::__storage_type __storage_type; - static const unsigned __bits_per_word = _In::__bits_per_word; + static const int __bits_per_word = _In::__bits_per_word; difference_type __n = __last - __first; if (__n > 0) { @@ -551,7 +551,7 @@ typedef __bit_iterator<_Cp, _IsConst> _In; typedef typename _In::difference_type difference_type; typedef typename _In::__storage_type __storage_type; - static const unsigned __bits_per_word = _In::__bits_per_word; + static const int __bits_per_word = _In::__bits_per_word; difference_type __n = __last - __first; if (__n > 0) { @@ -600,7 +600,7 @@ typedef __bit_iterator<_Cp, _IsConst> _In; typedef typename _In::difference_type difference_type; typedef typename _In::__storage_type __storage_type; - static const unsigned __bits_per_word = _In::__bits_per_word; + static const int __bits_per_word = _In::__bits_per_word; difference_type __n = __last - __first; if (__n > 0) { @@ -718,7 +718,7 @@ typedef __bit_iterator<__C1, false> _I1; typedef typename _I1::difference_type difference_type; typedef typename _I1::__storage_type __storage_type; - static const unsigned __bits_per_word = _I1::__bits_per_word; + static const int __bits_per_word = _I1::__bits_per_word; difference_type __n = __last - __first; if (__n > 0) { @@ -768,7 +768,7 @@ typedef __bit_iterator<__C1, false> _I1; typedef typename _I1::difference_type difference_type; typedef typename _I1::__storage_type __storage_type; - static const unsigned __bits_per_word = _I1::__bits_per_word; + static const int __bits_per_word = _I1::__bits_per_word; difference_type __n = __last - __first; if (__n > 0) { @@ -880,7 +880,7 @@ typedef typename _Cp::__storage_type __storage_type; typedef typename _Cp::__storage_pointer __storage_pointer; typedef typename _Cp::iterator iterator; - static const unsigned __bits_per_word = _Cp::__bits_per_word; + static const int __bits_per_word = _Cp::__bits_per_word; static const unsigned _Np = 4; difference_type __size_; @@ -959,7 +959,7 @@ typedef __bit_iterator<_Cp, _IC1> _It; typedef typename _It::difference_type difference_type; typedef typename _It::__storage_type __storage_type; - static const unsigned __bits_per_word = _It::__bits_per_word; + static const int __bits_per_word = _It::__bits_per_word; difference_type __n = __last1 - __first1; if (__n > 0) { @@ -1041,7 +1041,7 @@ typedef __bit_iterator<_Cp, _IC1> _It; typedef typename _It::difference_type difference_type; typedef typename _It::__storage_type __storage_type; - static const unsigned __bits_per_word = _It::__bits_per_word; + static const int __bits_per_word = _It::__bits_per_word; difference_type __n = __last1 - __first1; if (__n > 0) { @@ -1101,7 +1101,7 @@ typedef typename _Cp::__storage_type __storage_type; typedef typename conditional<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>::type __storage_pointer; - static const unsigned __bits_per_word = _Cp::__bits_per_word; + static const int __bits_per_word = _Cp::__bits_per_word; __storage_pointer __seg_; unsigned __ctz_; Index: include/deque =================================================================== --- include/deque +++ include/deque @@ -2735,7 +2735,7 @@ difference_type __pos = __f - __b; iterator __p = __b + __pos; allocator_type& __a = __base::__alloc(); - if (__pos <= (__base::size() - 1) / 2) + if (static_cast(__pos) <= (__base::size() - 1) / 2) { // erase from front _VSTD::move_backward(__b, __p, _VSTD::next(__p)); __alloc_traits::destroy(__a, _VSTD::addressof(*__b)); Index: include/istream =================================================================== --- include/istream +++ include/istream @@ -1651,7 +1651,7 @@ ios_base::iostate __err = ios_base::goodbit; _CharT __zero = __ct.widen('0'); _CharT __one = __ct.widen('1'); - while (__c < _Size) + while (static_cast(__c) < _Size) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) Index: include/random =================================================================== --- include/random +++ include/random @@ -2918,7 +2918,7 @@ typename discard_block_engine<_Engine, __p, __r>::result_type discard_block_engine<_Engine, __p, __r>::operator()() { - if (__n_ >= __r) + if (__n_ >= 0 && static_cast(__n_) >= __r) { __e_.discard(__p - __r); __n_ = 0; Index: include/regex =================================================================== --- include/regex +++ include/regex @@ -6420,7 +6420,8 @@ _Position __prev = __position_; if (__result_ == &__suffix_) __result_ = nullptr; - else if (_N_ + 1 < __subs_.size()) + // _N_ should always be positive + else if (static_cast(_N_) + 1 < __subs_.size()) { ++_N_; __establish_result(); Index: include/vector =================================================================== --- include/vector +++ include/vector @@ -2914,7 +2914,9 @@ vector::assign(_ForwardIterator __first, _ForwardIterator __last) { clear(); - difference_type __n = _VSTD::distance(__first, __last); + const difference_type __ns = _VSTD::distance(__first, __last); + _LIBCPP_ASSERT(__ns >= 0, "invalid range specified"); + const size_type __n = static_cast(__ns); if (__n) { if (__n > capacity()) Index: test/libcxx/test/config.py =================================================================== --- test/libcxx/test/config.py +++ test/libcxx/test/config.py @@ -660,7 +660,7 @@ # team using the test suite; They enable the warnings below and # expect the test suite to be clean. # FIXME: Re-enable this after fixing remaining occurrences. - self.cxx.addWarningFlagIfSupported('-Wno-sign-compare') + self.cxx.addWarningFlagIfSupported('-Wsign-compare') # FIXME: Enable the two warnings below. self.cxx.addWarningFlagIfSupported('-Wno-unused-variable') self.cxx.addWarningFlagIfSupported('-Wno-unused-parameter')