From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id E1FF138582A1; Tue, 18 Jul 2023 11:00:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1FF138582A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689678023; bh=AzKDLUsYVU+pu+BkMseDb26yBpKju0I08uNXsxdaYrw=; h=From:To:Subject:Date:From; b=cX9csAnFLapnPLBeUKLHF0ShJYjmT8NG3ITU/bN2O3MX2qYAx660/Aw3XRnoHY4uj VeWRO35nxMd/tgN1vCF43geXrOAxBVYp2M0nMDaztA8xJClr9nwI0WXU+pOVCBa5dr vbCOvyH4Xh9fOb0stJdo5rUKyGXwL8mjXuFWlHEQ= 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-7572] libstdc++: Qualify calls to debug mode helpers X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 2b4ca304b164e281b24e9d44ec480f65fac71a56 X-Git-Newrev: 5439234be2f4eb7e9764ffc4c26d31982669ad43 Message-Id: <20230718110023.E1FF138582A1@sourceware.org> Date: Tue, 18 Jul 2023 11:00:23 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5439234be2f4eb7e9764ffc4c26d31982669ad43 commit r13-7572-g5439234be2f4eb7e9764ffc4c26d31982669ad43 Author: Jonathan Wakely Date: Fri Jun 23 13:50:01 2023 +0100 libstdc++: Qualify calls to debug mode helpers These functions should be qualified to disable unwanted ADL. The overload of __check_singular_aux for safe iterators was previously being found by ADL, because it wasn't declared before __check_singular. Add a declaration so that it can be found by qualified lookup. libstdc++-v3/ChangeLog: * include/debug/helper_functions.h (__get_distance) (__check_singular, __valid_range_aux, __valid_range): Qualify calls to disable ADL. (__check_singular_aux(const _Safe_iterator_base*)): Declare overload that was previously found via ADL. (cherry picked from commit fa98bc4270dcb4ec78b5b1c0f4c067094c84bae6) Diff: --- libstdc++-v3/include/debug/helper_functions.h | 32 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/include/debug/helper_functions.h b/libstdc++-v3/include/debug/helper_functions.h index dccf8e9e5e6..052b36b484c 100644 --- a/libstdc++-v3/include/debug/helper_functions.h +++ b/libstdc++-v3/include/debug/helper_functions.h @@ -111,12 +111,19 @@ namespace __gnu_debug _GLIBCXX_CONSTEXPR inline typename _Distance_traits<_Iterator>::__type __get_distance(_Iterator __lhs, _Iterator __rhs) - { return __get_distance(__lhs, __rhs, std::__iterator_category(__lhs)); } + { + return __gnu_debug::__get_distance(__lhs, __rhs, + std::__iterator_category(__lhs)); + } // An arbitrary iterator pointer is not singular. inline bool __check_singular_aux(const void*) { return false; } + // Defined in + bool + __check_singular_aux(const class _Safe_iterator_base*); + // We may have an iterator that derives from _Safe_iterator_base but isn't // a _Safe_iterator. template @@ -125,7 +132,7 @@ namespace __gnu_debug __check_singular(_Iterator const& __x) { return ! std::__is_constant_evaluated() - && __check_singular_aux(std::__addressof(__x)); + && __gnu_debug::__check_singular_aux(std::__addressof(__x)); } /** Non-NULL pointers are nonsingular. */ @@ -163,7 +170,8 @@ namespace __gnu_debug std::input_iterator_tag) { return __first == __last - || (!__check_singular(__first) && !__check_singular(__last)); + || (!__gnu_debug::__check_singular(__first) + && !__gnu_debug::__check_singular(__last)); } template @@ -172,8 +180,8 @@ namespace __gnu_debug __valid_range_aux(_InputIterator __first, _InputIterator __last, std::random_access_iterator_tag) { - return - __valid_range_aux(__first, __last, std::input_iterator_tag()) + return __gnu_debug::__valid_range_aux(__first, __last, + std::input_iterator_tag()) && __first <= __last; } @@ -186,8 +194,8 @@ namespace __gnu_debug __valid_range_aux(_InputIterator __first, _InputIterator __last, std::__false_type) { - return __valid_range_aux(__first, __last, - std::__iterator_category(__first)); + return __gnu_debug::__valid_range_aux(__first, __last, + std::__iterator_category(__first)); } template @@ -197,10 +205,11 @@ namespace __gnu_debug typename _Distance_traits<_InputIterator>::__type& __dist, std::__false_type) { - if (!__valid_range_aux(__first, __last, std::input_iterator_tag())) + if (!__gnu_debug::__valid_range_aux(__first, __last, + std::input_iterator_tag())) return false; - __dist = __get_distance(__first, __last); + __dist = __gnu_debug::__get_distance(__first, __last); switch (__dist.second) { case __dp_none: @@ -231,7 +240,8 @@ namespace __gnu_debug typename _Distance_traits<_InputIterator>::__type& __dist) { typedef typename std::__is_integer<_InputIterator>::__type _Integral; - return __valid_range_aux(__first, __last, __dist, _Integral()); + return __gnu_debug::__valid_range_aux(__first, __last, __dist, + _Integral()); } template @@ -254,7 +264,7 @@ namespace __gnu_debug __valid_range(_InputIterator __first, _InputIterator __last) { typedef typename std::__is_integer<_InputIterator>::__type _Integral; - return __valid_range_aux(__first, __last, _Integral()); + return __gnu_debug::__valid_range_aux(__first, __last, _Integral()); } template