gcc-bugs@gcc.gnu.org
[Top] [All Lists]

[Bug middle-end/36296] wrong warning about potential uninitialized varia

Subject: [Bug middle-end/36296] wrong warning about potential uninitialized variable
From: "vincent at vinc17 dot org"
Date: 18 Aug 2008 22:58:26 -0000

------- 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

<Prev in Thread] Current Thread [Next in Thread>