From: Jonathan Wakely Date: Fri, 30 Jun 2023 20:09:01 +0000 (+0100) Subject: libstdc++: Qualify calls to std::_Destroy and _Destroy_aux X-Git-Tag: releases/gcc-12.4.0~327 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c4cd53ffd70205b2b136661b3be175dec0ce8d7;p=thirdparty%2Fgcc.git 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 --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index a4d06d3fc7ab..5cc52babef83 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -847,7 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Destroy(_ForwardIterator __first, _ForwardIterator __last, allocator<_Tp>&) { - _Destroy(__first, __last); + std::_Destroy(__first, __last); } _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/stl_construct.h b/libstdc++-v3/include/bits/stl_construct.h index 9531222809c6..a081f26adc33 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 000000000000..5623842e9b19 --- /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(); +}