This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/36296] wrong warning about potential uninitialized variable
- From: "vincent at vinc17 dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Aug 2008 22:58:26 -0000
- Subject: [Bug middle-end/36296] wrong warning about potential uninitialized variable
- References: <bug-36296-16207@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from vincent at vinc17 dot org 2008-08-18 22:58 -------
(In reply to comment #8)
> Please provide a preprocessed reduced testcase as similar to the original as
> possible.
Here's a similar testcase.
$ cat tst.c
void *foo (void);
void bar (void *);
void f (void)
{
int init = 0;
void *p;
while (1)
{
if (init == 0)
{
p = foo ();
init = 2;
}
bar (p);
}
}
$ gcc -Wall -O2 tst.c -c
tst.c: In function 'f':
tst.c:7: warning: 'p' may be used uninitialized in this function
This is quite strange: if I replace the value 2 by 1 or if I replace foo() by
0, the warning is no longer displayed.
Note: in the reality (in MPFR), the variable I called init here is the size of
the array (0 when the array hasn't been allocated yet).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36296