From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id EF6483885C2F for ; Fri, 17 Feb 2023 14:02:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF6483885C2F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from r6.localdomain (82-217-174-174.cable.dynamic.v4.ziggo.nl [82.217.174.174]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 4BA5E3000648; Fri, 17 Feb 2023 15:01:59 +0100 (CET) Received: by r6.localdomain (Postfix, from userid 1000) id E04363401CE; Fri, 17 Feb 2023 15:01:58 +0100 (CET) Message-ID: <4bac5d2f550243e2782e4477aeb29fdb1c331a0a.camel@klomp.org> Subject: Re: Missed warning (-Wuse-after-free) From: Mark Wielaard To: Siddhesh Poyarekar , Alejandro Colomar , GCC Cc: Iker Pedrosa , David Malcolm , Florian Weimer , Sam James , Paul Eggert , Michael Kerrisk , Martin Uecker , =?UTF-8?Q?J=E2=82=91=E2=82=99=E2=82=9B?= Gustedt , Yann Droneaud Date: Fri, 17 Feb 2023 15:01:58 +0100 In-Reply-To: References: <8ed6d28c-69dc-fed8-5ab5-99f685f06fac@gmail.com> <38e7e994a81d2a18666404dbaeb556f3508a6bd6.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-3029.8 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_SHORT,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no 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 Fri, 2023-02-17 at 08:38 -0500, Siddhesh Poyarekar wrote: > On 2023-02-17 06:22, Alejandro Colomar wrote: > > Hi Siddhesh, > >=20 > > On 2/17/23 04:48, Siddhesh Poyarekar wrote: > > > On 2023-02-16 10:15, David Malcolm via Gcc wrote: > > > > I'm not convinced that it's useful to the end-user to warn about th= e > > > > "use of q itself" case. > > >=20 > > > FWIW, -Wuse-after-free=3D3 already should do this: > >=20 > > Thanks! It works. I would have expected such a warning to be included > > in -Wextra. Does it have any false positives (or maybe too many false > > negatives?) that make it unsuitable for -Wextra? >=20 > I don't know why it isn't enabled in -Wextra, it seems like the right=20 > thing to do. Interesting warning flag I didn't know about. It seems to have found an issue in some code trying to free a circular single linked list: https://inbox.sourceware.org/elfutils-devel/20230217140027.125332-1-mark@kl= omp.org/ The reason people might not know about it, is that the documentation is somewhat unclear. -Wall says it already includes -Wuse-after-free=3D3: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall But the -Wuse-after-free option itself says -Wall only enables -Wuse- after-free=3D2: https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-W= use-after-free Also note that it is listed under "Options Controlling C++ Dialect" so it wasn't immediately clear to me that it also works for C. Cheers, Mark