From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 8D9803AA7CA0 for ; Thu, 5 Aug 2021 14:21:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D9803AA7CA0 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-AVt3vStBM9ew6H0f2_aTgA-1; Thu, 05 Aug 2021 10:21:31 -0400 X-MC-Unique: AVt3vStBM9ew6H0f2_aTgA-1 Received: by mail-wr1-f72.google.com with SMTP id p12-20020a5d68cc0000b02901426384855aso1984658wrw.11 for ; Thu, 05 Aug 2021 07:21:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/hPFYvxCy9kJv/EXpsULiLQ/4se6cbjkDNwBwX8/10g=; b=UIcu4oj0gFNsrMkfkC2c98clrRzTMC1bYrWmMbiX3Mi4Pzgpvjy2B6U3fXiLf1ev2E Lyv899kGiOMKz/esnTtBqxTNdusosEiOmU4A4UfICBm7/O48IsSESRTCwPX3Vs9z5VJT OOMz4POklNDQJmPzX1lYH8/PhuKeji01G991FT21cHJvEQYddm7K9UHCQVFAdJFM+y87 vE7bQ4Soqa50bJuHUDOy2V+soupAkEnrf7M6MlW0+l8hAgWIoHxzR1oEDBgtDjf/npeq /2GS5Qt0O99gOQcOKPSLan8Fwpg/1GisMv3Iy0Ym1U2B1zu08NvWlZ1D75xcClWk9uXl zHIw== X-Gm-Message-State: AOAM531zOCb9tCmD2axtyNxdzUfqRtW4g+sUojrMq8HbUyXSyCHE4bLh YbOgrXTHNCcuiXgauwmoMDnAMAFzsWuvtnfjYj2UFct9D2gb85G1YXguugrfK4qLiJFU9yK/7yj 8lCuFqB9E1NbDQ8P0FLtNUQoVC5OEufA= X-Received: by 2002:a05:600c:1d11:: with SMTP id l17mr5468316wms.185.1628173290425; Thu, 05 Aug 2021 07:21:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+JJlpPl+bWesEq5UaHvduAURllVaxp2qdx+AobdaqoqeYwuJnX0tlkB1hV4N3Wxt8skTzM4Xvc1UxS4PG3w8= X-Received: by 2002:a05:600c:1d11:: with SMTP id l17mr5468295wms.185.1628173290240; Thu, 05 Aug 2021 07:21:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Thu, 5 Aug 2021 15:21:19 +0100 Message-ID: Subject: Re: [committed 2/2] libstdc++: Add [[nodiscard]] to sequence containers To: Ville Voutilainen Cc: Christophe Lyon , "libstdc++" , GCC Patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="00000000000099207405c8d0a290" X-Spam-Status: No, score=-12.7 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_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2021 14:21:35 -0000 --00000000000099207405c8d0a290 Content-Type: text/plain; charset="UTF-8" On Thu, 5 Aug 2021 at 13:14, Ville Voutilainen wrote: > > On Thu, 5 Aug 2021 at 15:11, Christophe Lyon via Libstdc++ > wrote: > > > > Hi Jonathan, > > > > On Wed, Aug 4, 2021 at 2:04 PM Jonathan Wakely via Gcc-patches < > > gcc-patches@gcc.gnu.org> wrote: > > > > > On 04/08/21 12:56 +0100, Jonathan Wakely wrote: > > > >... and container adaptors. > > > > > > > >This adds the [[nodiscard]] attribute to functions with no side-effects > > > >for the sequence containers and their iterators, and the debug versions > > > >of those containers, and the container adaptors, > > > > > > I don't plan to add any more [[nodiscard]] attributes for now, but > > > these two commits should demonstrate how to do it for anybody who > > > wants to contribute similar patches. > > > > > > I didn't add tests that verify we do actually warn on each of those > > > functions, because there are hundreds of them, and I know they're > > > working because I had to alter existing tests to not warn. > > > > > > > > I've noticed a regression on aarch64/arm: > > FAIL: g++.old-deja/g++.other/inline7.C -std=gnu++17 (test for excess > > errors) > > Excess errors: > > /gcc/testsuite/g++.old-deja/g++.other/inline7.C:11:11: warning: ignoring > > return value of 'std::__cxx11::list<_Tp, _Alloc>::size_type > > std::__cxx11::list<_Tp, _Alloc>::size() const [with _Tp = int*; _Alloc = > > std::allocator; std::__cxx11::list<_Tp, _Alloc>::size_type = long > > unsigned int]', declared with attribute 'nodiscard' [-Wunused-result] > > > > FAIL: g++.old-deja/g++.other/inline7.C -std=gnu++2a (test for excess > > errors) > > Excess errors: > > /gcc/testsuite/g++.old-deja/g++.other/inline7.C:11:11: warning: ignoring > > return value of 'std::__cxx11::list<_Tp, _Alloc>::size_type > > std::__cxx11::list<_Tp, _Alloc>::size() const [with _Tp = int*; _Alloc = > > std::allocator; std::__cxx11::list<_Tp, _Alloc>::size_type = long > > unsigned int]', declared with attribute 'nodiscard' [-Wunused-result] > > > > Not sure why you didn't see it? > > That can easily happen when running just the library tests, rather > than all of them. :P Right, I didn't run all the compiler tests. Fixed with this patch, tested x86_64-linux, pushed to trunk. --00000000000099207405c8d0a290 Content-Type: text/plain; charset="US-ASCII"; name="patch.txt" Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_krz0boje0 Y29tbWl0IDAzZDQ3ZGE3ZTFlOTFhZGRkYmRlMjYxZmZlZmQyNzYwZGY1OWE1NjQKQXV0aG9yOiBK b25hdGhhbiBXYWtlbHkgPGp3YWtlbHlAcmVkaGF0LmNvbT4KRGF0ZTogICBUaHUgQXVnIDUgMTQ6 MDA6MzUgMjAyMQoKICAgIHRlc3RzdWl0ZTogRml4IHdhcm5pbmcgaW50cm9kdWNlZCBieSBub2Rp c2NhcmQgaW4gbGlic3RkYysrCiAgICAKICAgIFNpZ25lZC1vZmYtYnk6IEpvbmF0aGFuIFdha2Vs eSA8andha2VseUByZWRoYXQuY29tPgogICAgCiAgICBnY2MvdGVzdHN1aXRlL0NoYW5nZUxvZzoK ICAgIAogICAgICAgICAgICAqIGcrKy5vbGQtZGVqYS9nKysub3RoZXIvaW5saW5lNy5DOiBDYXN0 IG5vZGlzY2FyZCBjYWxsIHRvIHZvaWQuCgpkaWZmIC0tZ2l0IGEvZ2NjL3Rlc3RzdWl0ZS9nKysu b2xkLWRlamEvZysrLm90aGVyL2lubGluZTcuQyBiL2djYy90ZXN0c3VpdGUvZysrLm9sZC1kZWph L2crKy5vdGhlci9pbmxpbmU3LkMKaW5kZXggYTM3MjNjZmJhMWUuLjYyNjAwMDAzOWM1IDEwMDY0 NAotLS0gYS9nY2MvdGVzdHN1aXRlL2crKy5vbGQtZGVqYS9nKysub3RoZXIvaW5saW5lNy5DCisr KyBiL2djYy90ZXN0c3VpdGUvZysrLm9sZC1kZWphL2crKy5vdGhlci9pbmxpbmU3LkMKQEAgLTgs NyArOCw3IEBAIHN0ZDo6bGlzdDxpbnQqPiBsaTsKIAogdm9pZCBmICgpCiB7Ci0gIGxpLnNpemUg KCk7CisgICh2b2lkKSBsaS5zaXplICgpOwogfQogCiBpbnQgbWFpbiAoKQo= --00000000000099207405c8d0a290--