From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 09C963856DC6; Tue, 18 Jul 2023 11:00:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09C963856DC6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689678029; bh=Kw36vmiooaZ8T20SVbOtZf9Wnu9LmFyJXw8D+NrGc/8=; h=From:To:Subject:Date:From; b=Jfis+qmLPg+stFGeRe7biK7GI3QLsYPF/l7fV+axz/iABS3eoOw3Daj0zTb8yikXv HTKqaXFCP9YV+U5xIbDgiXt57ks812hnQbqkpUGcesT+twl3jB/s5YAGvXh+v1WX/H 5eVnKz3VRp9Nnqor3TV1Xn2+1ZeDK4j5bOTMy5mQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-7573] libstdc++: Qualify calls to std::_Destroy and _Destroy_aux X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 5439234be2f4eb7e9764ffc4c26d31982669ad43 X-Git-Newrev: dae963588777df4317cdf81740a4b3de8debd78b Message-Id: <20230718110029.09C963856DC6@sourceware.org> Date: Tue, 18 Jul 2023 11:00:29 +0000 (GMT) List-Id: https://gcc.gnu.org/g:dae963588777df4317cdf81740a4b3de8debd78b commit r13-7573-gdae963588777df4317cdf81740a4b3de8debd78b Author: Jonathan Wakely 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. (cherry picked from commit 33245d6b87a284495304c9952813b6b83d5df99f) 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::__destroy(__first, __last); + return std::_Destroy_aux::__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::__destroy_n(__first, __count); + return std::_Destroy_n_aux::__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 + +template struct Holder { T t; }; // { dg-bogus "incomplete type" } +struct Incomplete; + +void destroy(std::vector*>* p) +{ + p->~vector(); +}