public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/60488] New: missing -Wmaybe-uninitialized on a conditional with goto
Date: Mon, 10 Mar 2014 16:17:00 -0000	[thread overview]
Message-ID: <bug-60488-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 60488
           Summary: missing -Wmaybe-uninitialized on a conditional with
                    goto
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gmail dot com

The -Wmaybe-uninitialized option is documented like so: "For an automatic
variable, if there exists a path from the function entry to a use of the
variable that is initialized, but there exist some other paths for which the
variable is not initialized, the compiler emits a warning if it cannot prove
the uninitialized paths are not executed at run time."

In the program below, when f(&a) returns zero, the variable b is considered to
have been initialized by the call to f(&b) when it's used as the argument in
the first call to g(b). However, when f(&a) returns non-zero, the variable b is
used uninitialized in the second call to g(b). Therefore, there exists a path
through the function where b is used initialized as well as one where it's used
uninitialized. Thus, GCC should issue a warning. It, however, does not.

$ cat t.c && gcc -O2 -Wuninitialized -Wmaybe-uninitialized -c -o/dev/null t.c
int f (int**);
void g (int*);

int foo (void) {
    int *a, *b;

    if (f (&a) || f (&b))
        goto end;

    g (a);
    g (b);
    return 0;
end:
    g (b);
    return 1;
}


             reply	other threads:[~2014-03-10 16:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10 16:17 msebor at gmail dot com [this message]
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
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@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).