Bug 27289

Summary: Gcc produces spurious -Wuninitialized warning compiling gdb
Product: gcc Reporter: fnf <fnf>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Severity: normal CC: av1474, edwin+bugs, fnf, gcc-bugs, j.w.r.degoede, manu, mkoegler, rolandsun, rth, thutt, trick, william
Priority: P3    
Version: 4.2.0   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed: 2008-02-01 17:10:16
Bug Depends on:    
Bug Blocks: 24639    

Description fnf@specifix.com 2006-04-24 16:52:01 UTC

When building gdb with -Werror, the compile fails due to what looks
like a spurious warning from using -Wuninitialized.  I've reduced the
testcase down to a minimal one, hopefully preserving the original
cause of the warning.

System: Linux puffer.diveadx.com 2.6.16-1.2069_FC4smp #1 SMP Tue Mar 28 12:47:32 EST 2006 i686 i686 i386 GNU/Linux
Architecture: i686

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /src/latest/trunk/src/gcc/configure -v --prefix=/opt/local/latest/trunk --enable-languages=c,c++ --cache-file=.././config.cache --srcdir=/src/latest/trunk/src/gcc


/* Run as:

     $ gcc -c -O2 -Wuninitialized bug.c
     bug.c: In function ‘foo’:
     bug.c:19: warning: ‘tmp_obstack.chunk_size’ may be used uninitialized in this function

struct obstack
  long chunk_size;

static struct obstack dont_print_statmem_obstack;

foo (int dont_print_statmem, int start)
  int i;
  struct obstack tmp_obstack;

  if (dont_print_statmem == 0)
      tmp_obstack = dont_print_statmem_obstack;

  for (i = start; i < 7; i++)

  if (dont_print_statmem == 0)
      dont_print_statmem_obstack = tmp_obstack;
Comment 1 Andrew Pinski 2006-04-24 17:06:35 UTC
This is the old problem referenced in PR 5035.

*** This bug has been marked as a duplicate of 5035 ***
Comment 2 Manuel López-Ibáñez 2008-02-01 17:00:53 UTC
Not a duplicate of PR 5035, sice that one is fixed and this isn't. 
Comment 3 Manuel López-Ibáñez 2008-02-01 17:05:33 UTC
... to mark as a duplicate of PR 29479. They are almost the same testcase.

*** This bug has been marked as a duplicate of 29479 ***
Comment 4 Manuel López-Ibáñez 2008-02-01 17:08:25 UTC
Argh, the other way around (this testcase is shorter).
Comment 5 Manuel López-Ibáñez 2008-02-01 17:08:39 UTC
*** Bug 29479 has been marked as a duplicate of this bug. ***
Comment 6 Manuel López-Ibáñez 2008-02-01 17:10:16 UTC
Confirmed with GNU C (GCC) version 4.3.0 20080122 (experimental) (x86_64-unknown-linux-gnu)
Comment 7 Manuel López-Ibáñez 2009-02-07 15:05:49 UTC
This needs conditional PHIs (or smarter propagation) so a duplicate of bug 36550

*** This bug has been marked as a duplicate of 36550 ***