public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vultkayn at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/110830] New: -Wanalyzer-use-of-uninitialized-value false negative due to use-after-free::supercedes_p.
Date: Thu, 27 Jul 2023 12:41:41 +0000	[thread overview]
Message-ID: <bug-110830-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110830

            Bug ID: 110830
           Summary: -Wanalyzer-use-of-uninitialized-value false negative
                    due to use-after-free::supercedes_p.
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: vultkayn at gcc dot gnu.org
  Target Milestone: ---

state_machine::supercedes_p is called when two diagnostics are emitted for the
same statement, without regarding the path that led to this statement.
See reproducer on trunk https://godbolt.org/z/GqebW5s5h 

#include <stdlib.h>

extern int ext();

int* foo()
{
  int *p = 0;
  if (ext() > 5)
  {
    p = malloc (sizeof(int));
    *p = 0;
    free (p);
    return p;
  }
  else
    return malloc(sizeof(int));
}

void test()
{
  int *y = foo(); // (*)
  int x = 4 + *y;
  free (y);
}

At statement (*) both -Wanalyzer-use-of-uninitialized-value and
-Wanalyzer-use-after-free should be emitted as solving the latter won't impact
the former, since they result from two independent branches. But
use_after_free::supercedes_p hides the other.

In the case of a false positive -Wanalyzer-use-after-free, or simply one
ignored by the user, the adjacent -Wanalyzer-use-of-uninitialized-value would
therefore never be emitted.

             reply	other threads:[~2023-07-27 12:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27 12:41 vultkayn at gcc dot gnu.org [this message]
2023-07-31 22:40 ` [Bug analyzer/110830] " dmalcolm at gcc dot gnu.org
2023-07-31 22:43 ` dmalcolm at gcc dot gnu.org
2023-09-07 21:02 ` cvs-commit at gcc dot gnu.org

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=bug-110830-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).