public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r14-2272] libstdc++: Qualify calls to std::_Destroy and _Destroy_aux
Date: Mon,  3 Jul 2023 23:06:32 +0000 (GMT)	[thread overview]
Message-ID: <20230703230632.39E3C3858436@sourceware.org> (raw)

https://gcc.gnu.org/g:33245d6b87a284495304c9952813b6b83d5df99f

commit r14-2272-g33245d6b87a284495304c9952813b6b83d5df99f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jun 30 21:09:01 2023 +0100

    libstdc++: Qualify calls to std::_Destroy and _Destroy_aux
    
    These calls should be qualified to prevent ADL, which can cause errors
    for incomplete types that are associated classes.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/alloc_traits.h (_Destroy): Qualify call.
            * include/bits/stl_construct.h (_Destroy, _Destroy_n): Likewise.
            * testsuite/23_containers/vector/cons/destroy-adl.cc: New test.

Diff:
---
 libstdc++-v3/include/bits/alloc_traits.h                      |  2 +-
 libstdc++-v3/include/bits/stl_construct.h                     |  4 ++--
 .../testsuite/23_containers/vector/cons/destroy-adl.cc        | 11 +++++++++++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h
index cd91d152f64..182c3e23eed 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -944,7 +944,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _Destroy(_ForwardIterator __first, _ForwardIterator __last,
 	     allocator<_Tp>&)
     {
-      _Destroy(__first, __last);
+      std::_Destroy(__first, __last);
     }
 #endif
   /// @endcond
diff --git a/libstdc++-v3/include/bits/stl_construct.h b/libstdc++-v3/include/bits/stl_construct.h
index 574f4fa50b4..cf62d927cdb 100644
--- a/libstdc++-v3/include/bits/stl_construct.h
+++ b/libstdc++-v3/include/bits/stl_construct.h
@@ -190,7 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 #if __cplusplus >= 202002L
       if (std::__is_constant_evaluated())
-	return _Destroy_aux<false>::__destroy(__first, __last);
+	return std::_Destroy_aux<false>::__destroy(__first, __last);
 #endif
       std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
 	__destroy(__first, __last);
@@ -239,7 +239,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 #if __cplusplus >= 202002L
       if (std::__is_constant_evaluated())
-	return _Destroy_n_aux<false>::__destroy_n(__first, __count);
+	return std::_Destroy_n_aux<false>::__destroy_n(__first, __count);
 #endif
       return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>::
 	__destroy_n(__first, __count);
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/destroy-adl.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/destroy-adl.cc
new file mode 100644
index 00000000000..5623842e9b1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/destroy-adl.cc
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+#include <vector>
+
+template<class T> struct Holder { T t; }; // { dg-bogus "incomplete type" }
+struct Incomplete;
+
+void destroy(std::vector<Holder<Incomplete>*>* p)
+{
+  p->~vector();
+}

                 reply	other threads:[~2023-07-03 23:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230703230632.39E3C3858436@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).