From patchwork Mon Jun 26 16:43:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 113047 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7613706vqr; Mon, 26 Jun 2023 09:45:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7F/LuyHwtV/dkOArMCb3t8+DCMhMihS27UgehWLlWrVx7GBbqq3WGKq6fh8sTE6CtQvgRc X-Received: by 2002:a17:907:9719:b0:98f:ab82:8893 with SMTP id jg25-20020a170907971900b0098fab828893mr3546466ejc.73.1687797946598; Mon, 26 Jun 2023 09:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687797946; cv=none; d=google.com; s=arc-20160816; b=pDVV9Uv2d5xbGc3gCuoWCJObDR2b/n62fymy2tDuChwhJJSdAnIX6M44gRjuG7N9P3 eQ92ZLpIWx0Ixki9HkPp2BnynPvnxz1/JVe3h4Ozduzj0/tKPLRXnATfAFujig6jles6 9TLQuYhiaJ2lqWyELWehxjX4xCUxbAUgHQXOXpkOlVbnJ/xWYPCuJN+zxN66RbMq4oNR Igc3909uuWURijRlCrTXQt+7QU5/TfoMI9VvQeLr7/SCd87wPUB5eC+piPU/HOLR7Kjh nOqq9qX3dreY/CJzEeB0NTjUC41piKgKogfJl51wSkQt1Sa/zAPH7fTKVSBi3pfkXX98 5g7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=sXNTHHUOxEn5jv3TcdxFjGaJUDhxwxaizLSJ7iV5iEs=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=N+plcvM/ZidQvH67E4+4NcLoJuWX6BSd1Hsioo7IbKDZZgRIvKZWJE6BiHhT4hRsnz Z2fbyiDIOaTn190lmc2NGM3tV2UjxdENW6RTG99iUMoXFBwJ7+sAxkGVVgxw71s9zZHl gyRkUrCnyYMJpZi6nkyzqdlI6QUCmaiyLA6JmQ4WLheEOxOSksOWI0Xsf/xVBlgtGxqq UL4iyilvt4rG45P2GH162+wGT/UH32d1QkW/TQxz0/v3tw/d+bHuCVR9ICc8ZMRQwcl2 naJ9rCn03bOzMqJqluRyjpPH8iH6oN8INRZfyd/KSaSYG+108/4L8gAEUrg24oMZBgJO pkPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=AYzRxYcC; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sb23-20020a170906edd700b0098871664f55si3032417ejb.800.2023.06.26.09.45.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 09:45:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=AYzRxYcC; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 361A53850419 for ; Mon, 26 Jun 2023 16:44:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 361A53850419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687797882; bh=sXNTHHUOxEn5jv3TcdxFjGaJUDhxwxaizLSJ7iV5iEs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=AYzRxYcCAzAvpizkBLdlFlUz8WnyQS5cnUAFRzgh7z5iF/NzF7UWhiV83bewxXe1z j0HTgyPRo7TCNlIE6+c/dftZ7LVeJy9KZ46VQnYd+2WrZ/+njm//5Tr7u+qLHMXjTU PXuhCYJZTtnDCTul0FOWgx7CEMs7wf5E0pJtOhJ8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id BEBDD3857C45 for ; Mon, 26 Jun 2023 16:43:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEBDD3857C45 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-578-FlIRMGVtM72n5UjDkE2k8Q-1; Mon, 26 Jun 2023 12:43:46 -0400 X-MC-Unique: FlIRMGVtM72n5UjDkE2k8Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5987C185A795; Mon, 26 Jun 2023 16:43:46 +0000 (UTC) Received: from localhost (unknown [10.42.28.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24A8040C2063; Mon, 26 Jun 2023 16:43:46 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Qualify calls to debug mode helpers Date: Mon, 26 Jun 2023 17:43:28 +0100 Message-ID: <20230626164345.270480-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769784419789058656?= X-GMAIL-MSGID: =?utf-8?q?1769784419789058656?= Tested x86_64-linux. Pushed to trunk. -- >8 -- 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. --- 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