------- Comment #2 from aldot at gcc dot gnu dot org  2008-06-17 10:46 -------
(In reply to comment #1)
> check() can return 1 on the first call and 0 on the second and if *argv is 
> NULL
> then then "bug" will be used uninitialized.

right, but this doesn't matter here. Better testcase:

/* { dg-do compile } */
/* { dg-options "-Os -Wuninitialized" } */
void bail(void) __attribute__((noreturn));
unsigned once(void);
int pr(char**argv)
{
        char *bug;
        unsigned check = once();
        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';
}


-- 


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

Reply via email to