Missed warning (-Wuse-after-free)

Alejandro Colomar alx.manpages@gmail.com
Fri Feb 17 11:22:53 GMT 2023

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?

> At level 3, the warning also diagnoses uses of indeterminate pointers in 
> equality expressions.  All uses of indeterminate pointers are undefined 
> but equality tests sometimes appear after
> calls to "realloc" as an attempt to determine whether the call resulted 
> in relocating the object to a different address.  They are diagnosed at 
> a separate level to aid legacy code gradually
> transition to safe alternatives.  For example, the equality test in the 
> function below is diagnosed at this level:
> Jakub and I had discussed this in the context of _FORTIFY_SOURCE=3 
> (which is anal about this and can break things) and we got pr#105217, 
> but that is also a best-effort thing, not really a guarantee.
> IMO the analyzer should go that extra mile and warn for the use of q 
> itself and maybe deprecate -Wuse-after-free=3 in its favour.
> Sid



GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20230217/8a216a75/attachment-0001.sig>

More information about the Gcc mailing list