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.
This commit is contained in:
Jonathan Wakely 2023-06-30 21:09:01 +01:00
parent 7c521f6751
commit 33245d6b87
3 changed files with 14 additions and 3 deletions

View file

@ -944,7 +944,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Destroy(_ForwardIterator __first, _ForwardIterator __last,
allocator<_Tp>&)
{
_Destroy(__first, __last);
std::_Destroy(__first, __last);
}
#endif
/// @endcond

View file

@ -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);

View file

@ -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();
}