Yet another one. It behaves the same for 4.1.2 and current trunk.

$ gcc -Os -Wuninitialized -c uninit-J.c
uninit-J.c: In function 'pr':
uninit-J.c:7: warning: 'bug' may be used uninitialized in this function

$ cat uninit-J.c
/* { dg-do compile } */
/* { dg-options "-Os -Wuninitialized" } */
void bail(void) __attribute__((noreturn));
unsigned check(void);
int pr(char**argv)
{
        char *bug;
        if (check()) {
                if (*argv)
                        bug = *++argv;
        } else {
                bug = *argv++;
                if (!*argv)
                        bail();
        }
        /* now bug is set except if (check() && !*argv) */
        if (check()) {
                if (!*argv)
                        return 0;
        }
        /* if we ever get here then bug is set */
        return *bug != 'X';
}


-- 
           Summary: Wrong "may be used uninitialized" warning
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aldot at gcc dot gnu dot org
OtherBugsDependingO 24639
             nThis:


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

Reply via email to