public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/60488] missing uninitialized warning (address taken,  VOP)
Date: Sat, 27 Mar 2021 08:57:03 +0000	[thread overview]
Message-ID: <bug-60488-4-ygCh5jdU25@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60488-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #6)
> The problem is that when the address of a variable escapes, because GCC
> doesn't track when, when the function from which it escapes calls another
> that might access the escaped variable, the warning (as a result of relying
> on the conservative assumptions the optimizers must make) assumes the called
> function initializes the variable.  Another example of this is function h()
> below.

I don't think these are equivalent testcases. It is OK to assume that the
invisible function initializes the variable. The problem arises when there is a
path that never calls the function but GCC does not see that.

The key here is the logical operator splits the possible paths in two. In one
of the paths, b (comment #5) is never initialized, no matter what you assume
about f(). It also happens with a simple if():

int f (int*);
int g(void);
int foo (void)
{
  int b;
  if (g()) {
    f(&b);
  }
  return b;
}

However, a similar construct without &b works:

int g(void);
int foo (void)
{
  int b;
  if (g()) {
    b = g();
  }
  return b;
}

If you look at the VOPs, there is a chain that goes from the VUSE of b to the
VDEF<(D)> through at least one PHI node.

The "return 0" is problematic because CPP (PR18501) will trigger and mess up
things even more. But the above testcases avoid PR18501 and still show this
bug.

  parent reply	other threads:[~2021-03-27  8:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10 16:17 [Bug c/60488] New: missing -Wmaybe-uninitialized on a conditional with goto msebor at gmail dot com
2014-06-25 19:43 ` [Bug middle-end/60488] " manu at gcc dot gnu.org
2014-06-25 19:44 ` manu at gcc dot gnu.org
2021-03-26 23:53 ` [Bug middle-end/60488] missing uninitialized warning (address taken, VOP) msebor at gcc dot gnu.org
2021-03-27  8:57 ` manu at gcc dot gnu.org [this message]
2021-03-29 17:43 ` msebor at gcc dot gnu.org
2021-03-30 16:25 ` manu at gcc dot gnu.org
2021-04-06 19:59 ` msebor 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-60488-4-ygCh5jdU25@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).