Bug 51544

Summary: uninitialized variable false positive prevents bootstrap with -fipa-cp-clone
Product: gcc Reporter: Matt Hargett <matt>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: dcb314
Priority: P3 Keywords: build, diagnostic
Version: 4.7.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 24639    

Description Matt Hargett 2011-12-14 00:56:38 UTC
I checked by hand, and this looks like a false positive to me. It doesn't come up without
-O[3,fast].

NOTE: I have hand-modified my build/bootstrap-lto.mk to use -Ofast. It's possible that using the bootstrap-O3 build-config will reproduce it as well.

$ ~/src/gcc-trunk/configure --enable-bootstrap --prefix=/home/matt
--enable-clocale=gnu --with-system-zlib --with-demangler-in-ld --enable-lto
--with-fpmath=sse --enable-languages=c,c++,lto
--with-build-config=bootstrap-lto --enable-build-with-cxx --disable-libmudflap
--with-cpu=core2 --with-tune=core2 --disable-libssp

$ make -j7 profiledbootstrap

/home/matt/src/gcc-trunk/gcc/cp/parser.c: In function ‘bool cp_parser_ctor_initializer_opt_and_function_body(cp_parser*)’:
/home/matt/src/gcc-trunk/gcc/cp/parser.c:17533:43: error: ‘list’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
Comment 1 Andrew Pinski 2011-12-14 01:01:33 UTC
Most likely what is happening is cp_parser_compound_statement is being inlined and it is not cost worthly to do the jump thread for check_body_p.
Comment 2 Matt Hargett 2011-12-14 20:52:30 UTC
Narrowed this down to -O2 -fipa-cp-clone that triggers the warning.
Comment 3 David Binderman 2013-01-31 18:03:04 UTC
I think I may be seeing something similar.

I've been trying to bootstrap using "-g -O3" in BOOT_CFLAGS. 
That doesn't work, but "-g -O2" of course does.

After trying out all the flags individually that
make the difference from -O2 to -O3, it is the -fipa-cp-clone
flag that is the only one that breaks bootstrap. The rest of 
the flags are fine.

On trunk snapshot of 20130130, I get

../../src/trunk/gcc/c/c-parser.c: In function ‘c_expr c_parser_postfix_expression_after_primary(c_parser*, location_t, c_expr)’:
../../src/trunk/gcc/c/c-parser.c:6908:16: error: ‘origtypes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
       origtypes);
                ^
This looks a false positive to me.
Comment 4 Marek Polacek 2013-02-12 19:21:39 UTC
http://gcc.gnu.org/ml/gcc-patches/2013-02/msg00324.html ought to fix the origtypes issue.
Comment 5 David Binderman 2013-03-09 20:07:48 UTC
(In reply to comment #3)
> I've been trying to bootstrap using "-g -O3" in BOOT_CFLAGS. 
> That doesn't work, but "-g -O2" of course does.

I am pleased to be able to say that BOOT_CFLAGS= -g -O3
works for revision 196574 (Sat 09 March 2013).

I'll use this as my new default build setting,
so when it stops working I'll be able to put in a bug report.

This is a long way from -g -O3 being the default
for all architectures, but it is a good step forward.

I think this bug is fixed.
Comment 6 Eric Gallager 2017-10-01 01:34:35 UTC
(In reply to David Binderman from comment #5)
> (In reply to comment #3)
> > I've been trying to bootstrap using "-g -O3" in BOOT_CFLAGS. 
> > That doesn't work, but "-g -O2" of course does.
> 
> I am pleased to be able to say that BOOT_CFLAGS= -g -O3
> works for revision 196574 (Sat 09 March 2013).
> 
> I'll use this as my new default build setting,
> so when it stops working I'll be able to put in a bug report.
> 
> This is a long way from -g -O3 being the default
> for all architectures, but it is a good step forward.
> 
> I think this bug is fixed.

OK, closing as FIXED then.