* [committed] libstdc++: Use std::addressof to avoid ADL for operator& [PR 60497]
@ 2021-04-30 14:48 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-04-30 14:48 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 663 bytes --]
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.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3833 bytes --]
commit 47915ef8477569b2fbd8001996aa4e542284bb24
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Apr 30 14:45:42 2021
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.
diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc
index f79aad97cf0..6285f734031 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 35b60865f58..0c13e744747 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 db532e3c585..ab1f49813df 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 550195a2749..96299129810 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 8a6a99fb537..caee5cbfc2f 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-30 14:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 14:48 [committed] libstdc++: Use std::addressof to avoid ADL for operator& [PR 60497] 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).