This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/36550] Wrong "may be used uninitialized" warning
- From: "aldot at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Jun 2008 10:46:57 -0000
- Subject: [Bug middle-end/36550] Wrong "may be used uninitialized" warning
- References: <bug-36550-11811@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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