From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id 8DB05385AC2E; Thu, 5 Aug 2021 12:14:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8DB05385AC2E Received: by mail-qk1-x72f.google.com with SMTP id z24so5971900qkz.7; Thu, 05 Aug 2021 05:14:10 -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=mFshz2p/yeJZNnv0ULmPRPNCA34bLaPgUh/JGvsUD/o=; b=R5p0TytJ+xDpGBM/b3p6OK5vjiGYa5ZOF69cLhzLAkUDfj6PVtedM7+TEZYzJ2BW6u eRIm2jKKykTnlVAhIqgSJ8YbsW0QOLKoy9BNogDt6SMqWU8eDYZB/6oc6ADCKTSwQc2f Td2I1e9kSZ7RoKeJcVdhwVFgXApsD35YwiGeXxFD+89GO/B2HjyVEm57h15QhOpyIfsV wDDRmF25i7MtdEOU8+c+IPMuuFrAi3sfNqNWtjqG7dOUN3OM+D1HVkVVs2Rl6Iaw1ckk dM6P3s4gjH+hr6tS9quteymbGway4yeLMrZL4lzZv+aHi7JnM52kfQJnKZLzQG3s1AXz 2h2g== X-Gm-Message-State: AOAM530VbxiFcumrgiaqr5cHRGD7wPyL+/nHKd77WFpdYysoFkwxiDU3 5+o2j378nnJCk9uLmLVxHPI5FvnogIcN/Osmfz0= X-Google-Smtp-Source: ABdhPJwuQ9yfCCWk5rE9/1QSiS+YDz+aat2m/ctx4P05xZ45muKFEatTM0hlBtkzMcDf2sY9bnSc2GBx123MhbkHFow= X-Received: by 2002:a05:620a:1298:: with SMTP id w24mr3357655qki.44.1628165648665; Thu, 05 Aug 2021 05:14:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ville Voutilainen Date: Thu, 5 Aug 2021 15:13:57 +0300 Message-ID: Subject: Re: [committed 2/2] libstdc++: Add [[nodiscard]] to sequence containers To: Christophe Lyon Cc: Jonathan Wakely , "libstdc++" , GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 12:14:12 -0000 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