From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A59631F4B4 for ; Sat, 2 Jan 2021 12:52:38 +0000 (UTC) Received: from localhost ([::1]:50182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvgOb-0000aR-8P for normalperson@yhbt.net; Sat, 02 Jan 2021 07:52:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvgNS-0007W0-Jv for bug-gnulib@gnu.org; Sat, 02 Jan 2021 07:51:26 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.160]:25422) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvgNQ-0008QQ-BR for bug-gnulib@gnu.org; Sat, 02 Jan 2021 07:51:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1609591881; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:From: Subject:Sender; bh=95PrlsSrZURx8ZEg2oTz/IJ9DCrY8XJv+gqxy2uUcNc=; b=QvxfR09QhtmxzqKfXYXVDKargazUAWfw4xrUnVRp7aqXnbuZUrH4N1uh8LvjcBk6Uh 7iSXxNb9Zn4StccFb01SO9ihhaGiWnC7y0I776+GQwRYhhoxC3/gcwVvkYklGFRosgWL iBG7qbjP1M1g0synyevBiLveoSk0e7bQg7RLGpa/kXlftTaVKH4bkdYIjzrm5P0hTifE LZW2cev7aCClQVhzZyVRbhrsCVb/c5mf6unOLhjySLe1ZC2PUm/HIQ8qLhtfM/OPhIWR hdKNfgt5IWVA2lAfgKM5bf/+HNtlDacETuDPg0qtp6j+9wnL7WPapsAs2gpO9f+E1cpa tblw== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6f3z/s=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.10.7 DYNA|AUTH) with ESMTPSA id e012d5x02CpJYlr (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sat, 2 Jan 2021 13:51:19 +0100 (CET) From: Bruno Haible To: Paul Eggert Subject: Re: test-getgroups.c:stringop-overflow warning on newer GCC Date: Sat, 02 Jan 2021 13:51:19 +0100 Message-ID: <2676740.EqFEuxarx6@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <42ae568f-9f49-bfb3-fbb8-6437fb8c50e1@cs.ucla.edu> References: <1918dba0-3f35-795d-df2c-48e107f725ea@bernhard-voelker.de> <42ae568f-9f49-bfb3-fbb8-6437fb8c50e1@cs.ucla.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.160; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-1.118, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bernhard Voelker , bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Paul Eggert wrote: > I see the problem on Fedora 33 as well. It doesn't appear to be a GCC > bug. unistd.h's declaration expands to this: > > extern int getgroups (int __size, __gid_t __list[]) __attribute__ > ((__nothrow__, __leaf__)) __attribute__ ((__access__ (__write_only__, 2, > 1))); > > and the "__write_only__, 2, 1" means that getgroup's 1st argument > specifies the number of items in the 2nd-argument array, which means if > the 1st argument is -1 the call is invalid. This checking is enabled by > -Wstringop-overflow=2 which is the GCC default in 10.2.1. I see. Thanks for explaining. Now that makes sense. 2021-01-02 Bruno Haible getgroups test: Avoid warning with glibc >= 2.32 and gcc >= 10. Reported by Bernhard Voelker in . * tests/test-getgroups.c: Silence gcc warnings of type -Wstringop-overflow. diff --git a/tests/test-getgroups.c b/tests/test-getgroups.c index 14e0e8f..dcea033 100644 --- a/tests/test-getgroups.c +++ b/tests/test-getgroups.c @@ -30,6 +30,15 @@ SIGNATURE_CHECK (getgroups, int, (int, gid_t[])); #include "macros.h" +/* Tell GCC not to warn about the specific edge cases tested here. + GCC >= 10 with glibc >= 2.32 would otherwise trigger warnings, even without + any -W options, because getgroups() is declared with + __attribute__ ((__access__ (__write_only__, 2, 1))) + */ +#if __GNUC__ >= 7 +# pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + int main (int argc, char **argv _GL_UNUSED) {