public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>,
	Alejandro Colomar <alx.manpages@gmail.com>, GCC <gcc@gcc.gnu.org>
Cc: "Iker Pedrosa" <ipedrosa@redhat.com>,
	"David Malcolm" <dmalcolm@redhat.com>,
	"Florian Weimer" <fweimer@redhat.com>,
	"Sam James" <sam@gentoo.org>, "Paul Eggert" <eggert@cs.ucla.edu>,
	"Michael Kerrisk" <mtk.manpages@gmail.com>,
	"Martin Uecker" <uecker@tugraz.at>,
	"Jₑₙₛ Gustedt" <jens.gustedt@inria.fr>,
	"Yann Droneaud" <ydroneaud@opteya.com>
Subject: Re: Missed warning (-Wuse-after-free)
Date: Fri, 17 Feb 2023 15:01:58 +0100	[thread overview]
Message-ID: <4bac5d2f550243e2782e4477aeb29fdb1c331a0a.camel@klomp.org> (raw)
In-Reply-To: <e8a6894b-f493-a147-9c9a-f83353896b84@gotplt.org>

On Fri, 2023-02-17 at 08:38 -0500, Siddhesh Poyarekar wrote:
> On 2023-02-17 06:22, Alejandro Colomar wrote:
> > Hi Siddhesh,
> > 
> > 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 the
> > > > "use of q itself" case.
> > > 
> > > FWIW, -Wuse-after-free=3 already should do this:
> > 
> > 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?
> 
> I don't know why it isn't enabled in -Wextra, it seems like the right 
> 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@klomp.org/

The reason people might not know about it, is that the documentation is
somewhat unclear. -Wall says it already includes -Wuse-after-free=3:
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=2:
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wuse-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

  reply	other threads:[~2023-02-17 14:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 14:35 Alejandro Colomar
2023-02-16 15:15 ` David Malcolm
2023-02-17  1:04   ` Alejandro Colomar
2023-02-17  1:05     ` Alejandro Colomar
2023-02-17  1:56       ` Sam James
2023-02-17  8:12     ` Martin Uecker
2023-02-17 11:35       ` Alejandro Colomar
2023-02-17 13:34         ` Andreas Schwab
2023-02-17 13:48         ` Martin Uecker
2023-02-23 19:23           ` Alex Colomar
2023-02-23 19:57             ` Martin Uecker
2023-02-24  0:02               ` Alex Colomar
2023-02-24  1:21                 ` Serge E. Hallyn
2023-02-24  1:42                   ` Alex Colomar
2023-02-24  3:01                     ` Peter Lafreniere
2023-02-24  8:52                       ` Martin Uecker
2023-02-24  8:43                     ` Martin Uecker
2023-02-24 16:10                     ` Serge E. Hallyn
2023-02-24  8:36                   ` Martin Uecker
2023-02-24 16:01                     ` Serge E. Hallyn
2023-02-24 16:37                       ` Martin Uecker
2023-02-17  3:48   ` Siddhesh Poyarekar
2023-02-17 11:22     ` Alejandro Colomar
2023-02-17 13:38       ` Siddhesh Poyarekar
2023-02-17 14:01         ` Mark Wielaard [this message]
2023-02-17 14:06           ` Siddhesh Poyarekar
2023-02-17 21:20         ` [PATCH] Make -Wuse-after-free=3 the default one in -Wall Alejandro Colomar
2023-02-17 21:39           ` Siddhesh Poyarekar
2023-02-17 21:41             ` Siddhesh Poyarekar
2023-02-17 22:58             ` Alejandro Colomar
2023-02-17 23:03               ` Siddhesh Poyarekar
2023-02-17 11:24     ` Missed warning (-Wuse-after-free) Jonathan Wakely
2023-02-17 11:43       ` Alejandro Colomar
2023-02-17 12:04         ` Jonathan Wakely
2023-02-17 12:53       ` Siddhesh Poyarekar
2023-02-17 14:10         ` Jonathan Wakely
2023-02-17 13:44     ` David Malcolm
2023-02-17 14:01       ` Siddhesh Poyarekar
2023-02-17  8:49 ` Yann Droneaud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4bac5d2f550243e2782e4477aeb29fdb1c331a0a.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=alx.manpages@gmail.com \
    --cc=dmalcolm@redhat.com \
    --cc=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=ipedrosa@redhat.com \
    --cc=jens.gustedt@inria.fr \
    --cc=mtk.manpages@gmail.com \
    --cc=sam@gentoo.org \
    --cc=siddhesh@gotplt.org \
    --cc=uecker@tugraz.at \
    --cc=ydroneaud@opteya.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).