libstdc++: Fix some warnings in headers
authorJonathan Wakely <jwakely@redhat.com>
Thu, 29 Oct 2020 11:43:55 +0000 (11:43 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 29 Oct 2020 11:43:55 +0000 (11:43 +0000)
These are usually suppressed without -Wsystem-headers.

libstdc++-v3/ChangeLog:

* include/bits/hashtable_policy.h (_Local_iterator_base): Cast
value to avoid -Wsign-compare warnings.
* include/bits/regex.h (sub_match::_M_str): Avoid narrowing
conversion.
* include/bits/regex_compiler.tcc (_Compiler::_M_quantifier):
Initialize variable to avoid -Wmaybe-uninitialized warning.
* include/bits/shared_ptr_base.h (_Sp_counted_deleter::_Impl):
Reorder mem-initializer-list to avoid -Wreorder warning.
* include/bits/stl_tree.h (_Rb_tree_impl): Explicitly
initialize base class in copy constructor.
* include/debug/safe_iterator.h (_Safe_iterator): Likewise.
* include/ext/debug_allocator.h: Reorder mem-initializer-list
to avoid -Wreorder warning.
* include/ext/throw_allocator.h (throw_allocator_limit)
(throw_allocator_random): Add user-declared assignment operators
to avoid -Wdeprecated-copy warnings.

libstdc++-v3/include/bits/hashtable_policy.h
libstdc++-v3/include/bits/regex.h
libstdc++-v3/include/bits/regex_compiler.tcc
libstdc++-v3/include/bits/shared_ptr_base.h
libstdc++-v3/include/bits/stl_tree.h
libstdc++-v3/include/debug/safe_iterator.h
libstdc++-v3/include/ext/debug_allocator.h
libstdc++-v3/include/ext/throw_allocator.h

index f5ce7209957561959d53e044eb6fa727f9bce73b..cea5e549d25343df893d6c76f956c0c8fb962806 100644 (file)
@@ -1368,7 +1368,7 @@ namespace __detail
 
       ~_Local_iterator_base()
       {
-       if (_M_bucket_count != -1)
+       if (_M_bucket_count != size_t(-1))
          _M_destroy();
       }
 
@@ -1376,7 +1376,7 @@ namespace __detail
       : __node_iter_base(__iter._M_cur), _M_bucket(__iter._M_bucket)
       , _M_bucket_count(__iter._M_bucket_count)
       {
-       if (_M_bucket_count != -1)
+       if (_M_bucket_count != size_t(-1))
          _M_init(*__iter._M_h());
       }
 
index 15e4289bf95e36fc190ae64c7c81171d88a4b0ca..3cbd0d5913e8c5e7217797c61dc0548ae300f577 100644 (file)
@@ -994,7 +994,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        _M_str() const noexcept
        {
          if (this->matched)
-           if (auto __len = this->second - this->first)
+           if (size_t __len = this->second - this->first)
              return { std::__addressof(*this->first), __len };
          return {};
        }
index 2ae4af02c89c17ada6cf0523fa0b6d38cdafcf91..c26b28a6965606f2fe2880b997a56258983c2d4a 100644 (file)
@@ -233,16 +233,16 @@ namespace __detail
          _StateSeqT __e(*_M_nfa, _M_nfa->_M_insert_dummy());
          long __min_rep = _M_cur_int_value(10);
          bool __infi = false;
-         long __n;
+         long __n = 0;
 
          // {3
          if (_M_match_token(_ScannerT::_S_token_comma))
-           if (_M_match_token(_ScannerT::_S_token_dup_count)) // {3,7}
-             __n = _M_cur_int_value(10) - __min_rep;
-           else
-             __infi = true;
-         else
-           __n = 0;
+           {
+             if (_M_match_token(_ScannerT::_S_token_dup_count)) // {3,7}
+               __n = _M_cur_int_value(10) - __min_rep;
+             else
+               __infi = true;
+           }
          if (!_M_match_token(_ScannerT::_S_token_interval_end))
            __throw_regex_error(regex_constants::error_brace,
                                "Unexpected end of brace expression.");
index 543783ba034ea9b60e72791e04de377a205bd5b3..368b2d7379ae12d256abc09f1955bbc744cafb94 100644 (file)
@@ -415,7 +415,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       public:
        _Impl(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept
-       : _M_ptr(__p), _Del_base(std::move(__d)), _Alloc_base(__a)
+       : _Del_base(std::move(__d)), _Alloc_base(__a), _M_ptr(__p)
        { }
 
        _Deleter& _M_del() noexcept { return _Del_base::_S_get(*this); }
index c50391d68c3a047ab00d53e89fbb6973f9a7e810..ec141ea01c76d447ecd5e91b75967af78e608720 100644 (file)
@@ -691,6 +691,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          _Rb_tree_impl(const _Rb_tree_impl& __x)
          : _Node_allocator(_Alloc_traits::_S_select_on_copy(__x))
          , _Base_key_compare(__x._M_key_compare)
+         , _Rb_tree_header()
          { }
 
 #if __cplusplus < 201103L
index 84a9f1d526d6a5dc5a98b3ad079d84154cd56622..9b77fac6478ba76c5cb7c4fca11a5b4c0fc8fc4d 100644 (file)
@@ -170,7 +170,7 @@ namespace __gnu_debug
        * @brief Copy construction.
        */
       _Safe_iterator(const _Safe_iterator& __x) _GLIBCXX_NOEXCEPT
-      : _Iter_base(__x.base())
+      : _Iter_base(__x.base()), _Safe_base()
       {
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // DR 408. Is vector<reverse_iterator<char*> > forbidden?
index 9946faa10a6db348f0f9f843db74164c6fa8f993..8b3941682eb9796ac0962dce946cebf3435d35c5 100644 (file)
@@ -112,10 +112,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _Alloc2>
        debug_allocator(const debug_allocator<_Alloc2>& __a2,
                        typename __convertible<_Alloc2>::__type = 0)
-       : _M_allocator(__a2._M_allocator), _M_extra(_S_extra()) { }
+       : _M_extra(_S_extra()), _M_allocator(__a2._M_allocator)  { }
 
       debug_allocator(const _Alloc& __a)
-      : _M_allocator(__a), _M_extra(_S_extra()) { }
+      : _M_extra(_S_extra()), _M_allocator(__a)  { }
 
       _GLIBCXX_NODISCARD pointer
       allocate(size_type __n)
index f99b26b0cf122fba8dca05a96d5c0d2008e8020f..0ab174f19a57ae3869349e6194f8e7658c80091b 100644 (file)
@@ -922,6 +922,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _GLIBCXX_USE_NOEXCEPT { }
 
       ~throw_allocator_limit() _GLIBCXX_USE_NOEXCEPT { }
+
+#if __cplusplus >= 201103L
+      throw_allocator_limit&
+      operator=(const throw_allocator_limit&) = default;
+#endif
     };
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
@@ -944,6 +949,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _GLIBCXX_USE_NOEXCEPT { }
 
       ~throw_allocator_random() _GLIBCXX_USE_NOEXCEPT { }
+
+#if __cplusplus >= 201103L
+      throw_allocator_random&
+      operator=(const throw_allocator_random&) = default;
+#endif
     };
 #endif // _GLIBCXX_USE_C99_STDINT_TR1