diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-06-30 21:09:01 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-07-04 00:05:53 +0100 |
commit | 33245d6b87a284495304c9952813b6b83d5df99f (patch) | |
tree | ef216a6ee01e829fdfeca1e2d8abbafc837892a3 | |
parent | 7c521f6751e47d9dfaca2c8288c65f94e2f54d3d (diff) | |
download | gcc-33245d6b87a284495304c9952813b6b83d5df99f.zip gcc-33245d6b87a284495304c9952813b6b83d5df99f.tar.gz gcc-33245d6b87a284495304c9952813b6b83d5df99f.tar.bz2 |
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.
-rw-r--r-- | libstdc++-v3/include/bits/alloc_traits.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_construct.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/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 cd91d15..182c3e2 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 574f4fa..cf62d92 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 0000000..5623842 --- /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(); +} |