* [committed] libstdc++: Fix some warnings in headers
@ 2020-10-29 22:52 Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2020-10-29 22:52 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 554 bytes --]
These are usually suppressed in system headers, but should be fixed
anyway.
libstdc++-v3/ChangeLog:
* include/bits/parse_numbers.h (_Select_int_base): Avoid
narrowing conversion in constant expression.
* include/experimental/buffer (buffer_copy): Avoid narrowing
conversion.
* include/experimental/internet (hash<>::operator()): Do not
use deprecated 'argument_type' member.
* include/std/variant (variant::emplace): Use cast instead
of implicit conversion from size_t to narrower unsigned type.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3863 bytes --]
commit d7aa21a3c78874743a42ffc1af3493ecb665496f
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Oct 29 22:47:22 2020
libstdc++: Fix some warnings in headers
These are usually suppressed in system headers, but should be fixed
anyway.
libstdc++-v3/ChangeLog:
* include/bits/parse_numbers.h (_Select_int_base): Avoid
narrowing conversion in constant expression.
* include/experimental/buffer (buffer_copy): Avoid narrowing
conversion.
* include/experimental/internet (hash<>::operator()): Do not
use deprecated 'argument_type' member.
* include/std/variant (variant::emplace): Use cast instead
of implicit conversion from size_t to narrower unsigned type.
diff --git a/libstdc++-v3/include/bits/parse_numbers.h b/libstdc++-v3/include/bits/parse_numbers.h
index 5e80907af09..923a56c5a9f 100644
--- a/libstdc++-v3/include/bits/parse_numbers.h
+++ b/libstdc++-v3/include/bits/parse_numbers.h
@@ -266,7 +266,7 @@ namespace __select_int
template<unsigned long long _Val, typename _IntType, typename... _Ints>
struct _Select_int_base<_Val, _IntType, _Ints...>
: conditional_t<(_Val <= __gnu_cxx::__int_traits<_IntType>::__max),
- integral_constant<_IntType, _Val>,
+ integral_constant<_IntType, (_IntType)_Val>,
_Select_int_base<_Val, _Ints...>>
{ };
diff --git a/libstdc++-v3/include/experimental/buffer b/libstdc++-v3/include/experimental/buffer
index 8ccdb28cc5b..08d3a365e8d 100644
--- a/libstdc++-v3/include/experimental/buffer
+++ b/libstdc++-v3/include/experimental/buffer
@@ -315,7 +315,7 @@ inline namespace v1
inline size_t
buffer_copy(const _MutableBufferSequence& __dest,
const _ConstBufferSequence& __source) noexcept
- { return net::buffer_copy(__dest, __source, size_t{-1}); }
+ { return net::buffer_copy(__dest, __source, size_t(-1)); }
// buffer arithmetic:
diff --git a/libstdc++-v3/include/experimental/internet b/libstdc++-v3/include/experimental/internet
index f1153b8ff6a..1143ef41a5a 100644
--- a/libstdc++-v3/include/experimental/internet
+++ b/libstdc++-v3/include/experimental/internet
@@ -2393,7 +2393,7 @@ namespace ip
: __hash_base<size_t, experimental::net::v1::ip::address>
{
size_t
- operator()(const argument_type& __a) const
+ operator()(const experimental::net::v1::ip::address& __a) const
{
if (__a.is_v4())
return _Hash_impl::hash(__a.to_v4());
@@ -2407,7 +2407,7 @@ namespace ip
: __hash_base<size_t, experimental::net::v1::ip::address_v4>
{
size_t
- operator()(const argument_type& __a) const
+ operator()(const experimental::net::v1::ip::address_v4& __a) const
{ return _Hash_impl::hash(__a.to_bytes()); }
};
@@ -2415,7 +2415,7 @@ namespace ip
: __hash_base<size_t, experimental::net::v1::ip::address_v6>
{
size_t
- operator()(const argument_type& __a) const
+ operator()(const experimental::net::v1::ip::address_v6& __a) const
{ return _Hash_impl::hash(__a.to_bytes()); }
};
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 17f8bcd638b..4455ff4f073 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1512,7 +1512,8 @@ namespace __variant
}
__catch (...)
{
- this->_M_index = variant_npos;
+ using __index_type = decltype(this->_M_index);
+ this->_M_index = static_cast<__index_type>(variant_npos);
__throw_exception_again;
}
}
@@ -1559,7 +1560,8 @@ namespace __variant
}
__catch (...)
{
- this->_M_index = variant_npos;
+ using __index_type = decltype(this->_M_index);
+ this->_M_index = static_cast<__index_type>(variant_npos);
__throw_exception_again;
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [committed] libstdc++: Fix some warnings in headers
@ 2020-10-29 11:44 Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2020-10-29 11:44 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 962 bytes --]
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.
Tested x86_64-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 6730 bytes --]
commit eb6b71b83c9f099808bc50c6a467a0caf4002e50
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Oct 29 11:43:55 2020
libstdc++: Fix some warnings in headers
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.
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index f5ce7209957..cea5e549d25 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -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());
}
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 15e4289bf95..3cbd0d5913e 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -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 {};
}
diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc
index 2ae4af02c89..c26b28a6965 100644
--- a/libstdc++-v3/include/bits/regex_compiler.tcc
+++ b/libstdc++-v3/include/bits/regex_compiler.tcc
@@ -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.");
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 543783ba034..368b2d7379a 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -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); }
diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
index c50391d68c3..ec141ea01c7 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -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
diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h
index 84a9f1d526d..9b77fac6478 100644
--- a/libstdc++-v3/include/debug/safe_iterator.h
+++ b/libstdc++-v3/include/debug/safe_iterator.h
@@ -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?
diff --git a/libstdc++-v3/include/ext/debug_allocator.h b/libstdc++-v3/include/ext/debug_allocator.h
index 9946faa10a6..8b3941682eb 100644
--- a/libstdc++-v3/include/ext/debug_allocator.h
+++ b/libstdc++-v3/include/ext/debug_allocator.h
@@ -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)
diff --git a/libstdc++-v3/include/ext/throw_allocator.h b/libstdc++-v3/include/ext/throw_allocator.h
index f99b26b0cf1..0ab174f19a5 100644
--- a/libstdc++-v3/include/ext/throw_allocator.h
+++ b/libstdc++-v3/include/ext/throw_allocator.h
@@ -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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-29 22:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 22:52 [committed] libstdc++: Fix some warnings in headers Jonathan Wakely
-- strict thread matches above, loose matches on Subject: below --
2020-10-29 11:44 Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).