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-m...@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