Bug 36823

Summary: missing uninitialzied warning (IPA, inlining)
Product: gcc Reporter: heide-gcc
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: gcc-bugs, manu, pinskia
Priority: P3    
Version: 4.3.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2009-02-09 15:35:38
Bug Depends on:    
Bug Blocks: 24639    

Description heide-gcc 2008-07-14 14:02:27 UTC
Target: i686-pc-linux-gnulibc2
Configured with: ../configure --prefix=/tmp/gcc-4.3.1 --disable-nls --enable-shared --with-sysroot=/usr/i686-pc-linux-gnulibc2/ i686-pc-linux-gnulibc2
gcc version 4.3.1 (GCC)

$ gcc -O -Wall -Wuninitialized -c -o t.o t.c
$ gcc -O -Wall -Wuninitialized -fno-unit-at-a-time -c -o t.o t.c
t.c: In function 'f1':
t.c:14: warning: 'pp' may be used uninitialized in this function
$ cat t.c
struct a
{ struct a *n;
  struct b *b;
};

struct b
{ struct b *n;
};

extern struct a *a;

static int
f1 (struct b *b)
{ struct b *pp;
  struct b *p;
  for (p = b; p; p = p->n) pp = p;
  return (!pp);
}

int
f2 (void)
{ struct a *p;
  for (p = a; p; p = p->n) if (f1 (p->b)) return 0;
  return 1;
}

An older version of gcc (gcc (GCC) 3.3.3) works as expected.
A current version of gcc from Debian Unstable (gcc (Debian 4.3.1-6) 4.3.1)
shows the same failure
Comment 1 Andrew Pinski 2008-08-11 00:37:50 UTC
So what is happening is that we are saying pp is another name for p so it gets optimized as that.
Comment 2 Manuel López-Ibáñez 2009-02-09 15:35:38 UTC
After inlining, pp is initialized to 0.

 # BLOCK 3 freq:9550, starting at line 0
  # PRED: 10 [95.5%]  (true,exec)
  [/home/manuel/pr36823.c : 23] D.1611_4 = [/home/manuel/pr36823.c : 23] pD.1607_2->bD.1592;
  ppD.1620_9 = 0B;
  # SUCC: 4 [100.0%]  (fallthru,exec)

This doesn't seem to be CCP or anything else, but IPA. Something during IPA just assumes that the undefined value is 0.