diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-04-30 14:45:42 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-04-30 14:57:40 +0100 |
commit | 47915ef8477569b2fbd8001996aa4e542284bb24 (patch) | |
tree | 73bee53fec044b600b2df2bc154259a847b2a60e | |
parent | aa475c4ac80733f85ba47b109fc1900f05e810e2 (diff) | |
download | gcc-47915ef8477569b2fbd8001996aa4e542284bb24.zip gcc-47915ef8477569b2fbd8001996aa4e542284bb24.tar.gz gcc-47915ef8477569b2fbd8001996aa4e542284bb24.tar.bz2 |
libstdc++: Use std::addressof to avoid ADL for operator& [PR 60497]
This is another small step towards avoiding the problems described in PR
60497, by using std::addressof to avoid ADL, so that we don't require
all template arguments to be complete.
libstdc++-v3/ChangeLog:
PR libstdc++/60497
* include/bits/basic_ios.tcc (basic_ios::copyfmt): use
std::addressof.
* include/bits/basic_string.tcc (basic_string::swap)
(basic_string::assign): Likewise.
* include/bits/deque.tcc (deque::operator=(const deque&)):
Likewise.
* include/bits/stl_tree.h (_Rb_tree::operator=(const * _Rb_tree&)):
Likewise.
* include/bits/vector.tcc (vector::operator=(const vector&)):
Likewise.
-rw-r--r-- | libstdc++-v3/include/bits/basic_ios.tcc | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.tcc | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/deque.tcc | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_tree.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/vector.tcc | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc index f79aad9..6285f73 100644 --- a/libstdc++-v3/include/bits/basic_ios.tcc +++ b/libstdc++-v3/include/bits/basic_ios.tcc @@ -64,7 +64,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 292. effects of a.copyfmt (a) - if (this != &__rhs) + if (this != std::__addressof(__rhs)) { // Per 27.1.1, do not call imbue, yet must trash all caches // associated with imbue() diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 35b6086..0c13e74 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -58,7 +58,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION basic_string<_CharT, _Traits, _Alloc>:: swap(basic_string& __s) _GLIBCXX_NOEXCEPT { - if (this == &__s) + if (this == std::__addressof(__s)) return; _Alloc_traits::_S_on_swap(_M_get_allocator(), __s._M_get_allocator()); @@ -254,7 +254,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION basic_string<_CharT, _Traits, _Alloc>:: _M_assign(const basic_string& __str) { - if (this != &__str) + if (this != std::__addressof(__str)) { const size_type __rsize = __str.length(); const size_type __capacity = capacity(); diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index db532e3..ab1f498 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -95,7 +95,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER deque<_Tp, _Alloc>:: operator=(const deque& __x) { - if (&__x != this) + if (std::__addressof(__x) != this) { #if __cplusplus >= 201103L if (_Alloc_traits::_S_propagate_on_copy_assign()) diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 550195a..9629912 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -1729,7 +1729,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: operator=(const _Rb_tree& __x) { - if (this != &__x) + if (this != std::__addressof(__x)) { // Note that _Key may be a constant type. #if __cplusplus >= 201103L diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index 8a6a99f..caee5cb 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -198,7 +198,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER vector<_Tp, _Alloc>:: operator=(const vector<_Tp, _Alloc>& __x) { - if (&__x != this) + if (std::__addressof(__x) != this) { _GLIBCXX_ASAN_ANNOTATE_REINIT; #if __cplusplus >= 201103L |