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-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 C26DA1F5AE for ; Wed, 9 Jun 2021 13:35:51 +0000 (UTC) Received: from localhost ([::1]:57498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqyN4-0007Yk-G7 for normalperson@yhbt.net; Wed, 09 Jun 2021 09:35:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqyN0-0007YW-KK for bug-gnulib@gnu.org; Wed, 09 Jun 2021 09:35:46 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:53100) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqyMy-0000f0-CK for bug-gnulib@gnu.org; Wed, 09 Jun 2021 09:35:46 -0400 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id C00FC72C8B0; Wed, 9 Jun 2021 16:35:41 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id B0D6C7CF723; Wed, 9 Jun 2021 16:35:41 +0300 (MSK) Date: Wed, 9 Jun 2021 16:35:41 +0300 From: "Dmitry V. Levin" To: Paul Eggert Subject: Re: warnings in unit tests Message-ID: <20210609133541.GA28264@altlinux.org> References: <15897619.AQZsorJ5YP@omega> <4537093.ULRrrf3QbG@omega> <948c6b04-883b-0385-0cd1-77be21b3becd@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <948c6b04-883b-0385-0cd1-77be21b3becd@cs.ucla.edu> Received-SPF: pass client-ip=194.107.17.57; envelope-from=ldv@altlinux.org; helo=vmicros1.altlinux.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-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: noloader@gmail.com, bug-gnulib@gnu.org, Bruno Haible Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" On Tue, Jun 08, 2021 at 09:42:55AM -0700, Paul Eggert wrote: > For what it's worth I'm more with Bruno on this. For the tests, the cost > of these warnings outweighs the benefit. > > It'd be OK with me to disable the troublesome warnings globally for the > tests subdirectory, using -Wno-missing-prototypes or whatever. > > For the -Wnull-dereference issue it may be worthwhile to use a > circumlocution that fools GCC into not issuing the warning. After all, a > compiler smart enough to warn about '*(volatile int *) 0 = 42' might > also be smart enough to see that it's undefined behavior and therefore > omit the assignment's effect entirely. Perhaps something like the > attached (untested) patch? > diff --git a/tests/test-sigsegv-catch-stackoverflow2.c b/tests/test-sigsegv-catch-stackoverflow2.c > index b94d1310b..bfd4617a3 100644 > --- a/tests/test-sigsegv-catch-stackoverflow2.c > +++ b/tests/test-sigsegv-catch-stackoverflow2.c > @@ -50,6 +50,7 @@ sigset_t mainsigset; > > volatile int pass = 0; > uintptr_t page; > +int volatile *null_pointer_to_volatile; > > static void > stackoverflow_handler_continuation (void *arg1, void *arg2, void *arg3) > @@ -183,7 +184,7 @@ main () > *(volatile int *) (page + 0x678) = 42; > break; > case 3: > - *(volatile int *) 0 = 42; > + *null_pointer_to_volatile = 42; > break; > case 4: > break; Thanks, this patch works, I'd definitely prefer applying it rather than disabling -Wnull-dereference. -- ldv