From patchwork Tue Jan 21 22:26:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1226794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517944-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=Ix3YTYdz; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YbCY2aaa; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 482NSr13Vcz9sNx for ; Wed, 22 Jan 2020 09:27:22 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=VRQ84gnw5MboikRN snT5TZiEjXAoR0OUSEEnBRviqWdSN7GLSYC0NJGWTRYe1uNaop9Q3qMkx1segYiu QbpLizzijm/AeXJ+C7p51AGJadlh48wsOaDHe032VdPzJ5tZ+Is5pHk+ngJrVmz2 dRAOlh2zmU6mMqqKuyRjEFrPVdo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=789A/A+L/YT/0/D9pQzbF0 ZOurc=; b=Ix3YTYdzngMCEmz3PjSATKvhoF8HGGF0SdhMl3QIfJ8XxveEmSOGxs GymclkP0maRzL7OJ/qTvVzOtT8tBnOvqCLkPCoSfjZf9ZSiBwwTlk1x2HtChviJp YPV4IDXGVH4pddLooq77tnfqXiVYYEQsyXckuZ4r0z7E7zyQAkVaM= Received: (qmail 99579 invoked by alias); 21 Jan 2020 22:27:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 99563 invoked by uid 89); 21 Jan 2020 22:27:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jan 2020 22:27:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579645625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F+5qDVgSXFGke6WNTAmZ5iZ5PNYH8f0sVodle0LtYq0=; b=YbCY2aaaM0UPMiX0vpRaK/Umh0K7uR53QOTi0jJfDq4ji9o3uel6Buw3Hy7ewx7R9sweDl Hn21T6dn7ykbHhxZ01r7iXw6EXy540x6IhPacTBYDtctH3C9Y3yyBE1M40wGjn0FgVgbO0 AsL5CAi76R9PF3Ae+HrmgTPE7mkjpDg= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-157-1dVQYUSJMw-eyGDOSvRd9A-1; Tue, 21 Jan 2020 17:27:01 -0500 Received: by mail-qv1-f72.google.com with SMTP id g6so2630410qvp.0 for ; Tue, 21 Jan 2020 14:27:01 -0800 (PST) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id t23sm19732728qto.88.2020.01.21.14.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 14:27:00 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, jwakely@redhat.com, Patrick Palka Subject: [PATCH] libstdc++: Always return a sentinel from __gnu_test::test_range::end() Date: Tue, 21 Jan 2020 17:26:25 -0500 Message-Id: <20200121222625.3457862-1-ppalka@gcc.gnu.org> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes It seems that in practice std::sentinel_for is always true, and so the test_range container doesn't help us detect bugs in ranges code in which we wrongly assume that a sentinel can be manipulated like an iterator. Make the test_range container more strict by having end() unconditionally return a sentinel. Is this OK to commit after bootstrap+regtesting succeeds on x86_64-pc-linux-gnu? libstdc++-v3/ChangeLog: * testsuite/util/testsuite_iterators.h (__gnu_test::test_range::end): Always return a sentinel. --- libstdc++-v3/testsuite/util/testsuite_iterators.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index eb15257bf6a..6667a3af93a 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -702,10 +702,7 @@ namespace __gnu_test auto end() & { using I = decltype(get_iterator(bounds.last)); - if constexpr (std::sentinel_for) - return get_iterator(bounds.last); - else - return sentinel{bounds.last}; + return sentinel{bounds.last}; } typename Iter::ContainerType bounds;