From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by sourceware.org (Postfix) with ESMTPS id 0999C385828E for ; Fri, 17 Feb 2023 21:39:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0999C385828E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 578B654132F; Fri, 17 Feb 2023 21:39:48 +0000 (UTC) Received: from pdx1-sub0-mail-a306.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 738965412EA; Fri, 17 Feb 2023 21:39:47 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1676669987; a=rsa-sha256; cv=none; b=NljDa6J8B7pfvd9H9nrskaHnipKtvKVHsWADlo28Tnsd208/zThik91MoobU0jz5sBmxXB j9m+heso7BJd7SCYF04881SHSZDWl7I1vabNMBQSsWfJk043yLjQ8bm+fJ2Ag1YnN9xuHV OHlyy5iBCKFxh2n+lz55P8wnuTuRARw6/No1V8C50baj7ypiB6FxWCC2Tbu+77zu+aI7un PnhOXYslE7zGd+t+kdJBAchjYD/sfWHSBmj96hfqk7zCwWg7RUM82hbXrExHSlGD8HHz8Q pABzQ1j3l60GCrJPCzDjwnYe15y556UEAnLMmyycm2yfdFoEbUQTJFmggES8ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1676669987; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QSSzsWNmbjG3Tg1U0j9N0lmGH3+yT36WaG/u/XDNtCk=; b=6kkX4O0ZKHm6jkSFfEZHS7dzK7DpKx/rtin0NImfiaZq+1vecVCh/CCMUiXmQIgg/qda2o e3bl7vsPr2rlnIqF5nrRZezz6MuBeWuc90lSoGcjVwI0d9v+JMdhfc7JMIn2EcHM7rctVa HsiUeSkEgRHm2T3B3OMFDSd9sjyC5jgcx41gEOkc3+wsgTrDI5MDtwn2om07bjFLboUcPZ MIMtvXCJpqxezThoT2RtkBgyfniSYf+qo4s4RKd3UZiiHoS52lWxAzlPzJlOwjx2W937FD qe7iFafxQzOufPIKjAGTYixfOtUQIVIg6LxPkRfQ+mdelSAN1VMYU5LH0GkrUw== ARC-Authentication-Results: i=1; rspamd-5db48964c-2gs9c; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Plucky-Shade: 35a0be0f3ed3301d_1676669988137_605238181 X-MC-Loop-Signature: 1676669988137:3907943496 X-MC-Ingress-Time: 1676669988137 Received: from pdx1-sub0-mail-a306.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.103.24.101 (trex/6.7.1); Fri, 17 Feb 2023 21:39:48 +0000 Received: from [192.168.0.182] (unknown [174.91.45.59]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a306.dreamhost.com (Postfix) with ESMTPSA id 4PJQFX20Rsz3L; Fri, 17 Feb 2023 13:39:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1676669987; bh=QSSzsWNmbjG3Tg1U0j9N0lmGH3+yT36WaG/u/XDNtCk=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=tNe3vloPk1co0Cr1V3VAJNC1XmZhTvRR/mxdQSmFUr8tihUj6lZO7V+ODKS4ynEE5 jk/LM/6W2aMxB4FKtOsn9RqqR7ectfwzDrGn2ifKdoaVc3+T5uqY0g8a4vigLnlBSr Ckde4tgqa3t1SXqwoqw/LKkIKNqXWTA3ruI8F+jqVVMhVLzPeSlGuKF6GTEimgvOSb sKjAhrLlyaoZpggshT82ca6B3mmlKbQUcHbEJWB8YG246jYGkqb5LQkEMn0SZTavOf M2XtUWSTe11fbCJQAijfgQzMW5ssIvikVU6Gy9cBZ16Ams2yHAB+liikAfuMJrQkWs fKbSrXSsKOJIQ== Message-ID: <193404c7-20ac-7ba3-e010-f8921721fdb8@gotplt.org> Date: Fri, 17 Feb 2023 16:39:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] Make -Wuse-after-free=3 the default one in -Wall Content-Language: en-US To: Alejandro Colomar , gcc@gcc.gnu.org Cc: Alejandro Colomar , Andreas Schwab , David Malcolm , Florian Weimer , Iker Pedrosa , Jens Gustedt , Jonathan Wakely , Mark Wielaard , Martin Uecker , Michael Kerrisk , Paul Eggert , Sam James , Yann Droneaud References: <20230217212044.5178-1-alx@kernel.org> From: Siddhesh Poyarekar In-Reply-To: <20230217212044.5178-1-alx@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3036.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-02-17 16:20, Alejandro Colomar wrote: > Link: > Link: > Cc: Andreas Schwab > Cc: David Malcolm > Cc: Florian Weimer > Cc: Iker Pedrosa > Cc: Jens Gustedt > Cc: Jonathan Wakely > Cc: Mark Wielaard > Cc: Martin Uecker > Cc: Michael Kerrisk > Cc: Paul Eggert > Cc: Sam James > Cc: Siddhesh Poyarekar > Cc: Yann Droneaud > Signed-off-by: Alejandro Colomar > --- > > Hi Siddhesh, > > Here's a patch for it. It is untested yet. Please have a look at it. > I'm not used to GCC customs, so corrections are welcome :) > > Cheers, > > Alex You've got the customs right as far as submission is concerned; gcc accepts patches under DCO. I'm not a maintainer though, so I can't approve the change, I can only comment on it in the hope of influencing maintainers' opinions. In any case it's probably suitable as a proposal for gcc 14, given that 13 is in stage 4, regression fixes only. I'm split about where -Wuse-after-free=3 should be enabled. On the one hand, I'd like it to go into -Wall and alongside _FORTIFY_SOURCE=3, given that the latter already breaks the incorrect provenance assumptions in such code patterns. However on the other hand, it may lead to annoyed developers, even though the usage is, strictly speaking, UB. I don't know about the false positive rate of -Wuse-after-free=3 either (specifically in the context of UB-ness of the code it warns about), maybe someone else may be able to chime in on that. Maybe a good compromise here is -Wextra, but if there's consensus developing towards adding it to -Wall, I'll happily jump to that side. Thanks, Sid > > > gcc/c-family/c.opt | 4 ++-- > gcc/doc/invoke.texi | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt > index c0fea56a8f5..1a3fc2c5d74 100644 > --- a/gcc/c-family/c.opt > +++ b/gcc/c-family/c.opt > @@ -1411,11 +1411,11 @@ C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_unused_const_variable) > Warn when a const variable is unused. > > ; Defining this option here in addition to common.opt is necessary > -; in order for the default -Wall setting of -Wuse-after-free=2 to take > +; in order for the default -Wall setting of -Wuse-after-free=3 to take > ; effect. > > Wuse-after-free= > -LangEnabledBy(C ObjC C++ LTO ObjC++, Wall,2,0) > +LangEnabledBy(C ObjC C++ LTO ObjC++, Wall,3,0) > ; in common.opt > > Wvariadic-macros > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 7b308cd3c31..d910052ce0c 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -4720,7 +4720,7 @@ instead of pointers. This approach obviates needing to adjust the stored > pointers after reallocation. > @end table > > -@option{-Wuse-after-free=2} is included in @option{-Wall}. > +@option{-Wuse-after-free=3} is included in @option{-Wall}. > > @item -Wuseless-cast @r{(C++ and Objective-C++ only)} > @opindex Wuseless-cast