While looking at Bug 13000 I noticed this bug. Consider: static int foo (int a) { } int main (void) { return foo (0); } Compile this with "-O2 -Wall" and you can see that when finalizing `main' (after inlining foo of course), we produce this strange warning: t.i:2: warning: '({anonymous})' might be used uninitialized in this function Wtf :-) Of course this is a regression from mainline and older GCCs. -------------- $ cat t.i static int foo (int a) { } int main (void) { return foo (0); } $ cc1 --version GNU C version 3.5-tree-ssa 20031119 (merged 20031111) (i686-pc-linux-gnu) compiled by GNU C version 3.5-tree-ssa 20031119 (merged 20031111). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 $ cc1 -O -Wall t.i foo t.i: In function `foo': t.i:1: warning: control reaches end of non-void function main $ cc1 -O2 -Wall t.i main t.i: In function `main': t.i:2: warning: '({anonymous})' might be used uninitialized in this function
With little variations you can get all sorts of funny behavior: ================================== int foo () {} int main () { return foo(); } ================================== leads to x.cc: In function `int foo()': x.cc:1: warning: control reaches end of non-void function which looks OK to me. However, with ================================== int foo () {} int main () { return foo(); } ================================== I get x.cc: In function `int foo()': x.cc:1: warning: no return statement in function returning non-void x.cc: In function `int main()': x.cc:2: warning: '<anonymous>' might be used uninitialized in this function
Volker: How do the two code snippets differ? I think one should be different from the other, right? W.
Sorry. Cut-and-pasto. :-( The second example should read ================================== inline int foo () {} int main () { return foo(); } ==================================
Using my patch for 13863 (which I am about to post) and setting TREE_NO_WARNING for the decl which was created, this will be fixed. Mine as I can fix this.
the fix would be set TREE_NO_WARNING in declare_return_variable on var, will test after the patch for 13863 is done testing.
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-02/msg00561.html>.
Subject: Bug 13127 CVSROOT: /cvs/gcc Module name: gcc Branch: tree-ssa-20020619-branch Changes by: pinskia@gcc.gnu.org 2004-02-06 21:30:06 Modified files: gcc : ChangeLog.tree-ssa tree-inline.c gcc/testsuite : ChangeLog.tree-ssa Added files: gcc/testsuite/gcc.dg: 20040206-1.c Log message: 2004-02-06 Andrew Pinski <pinskia@physics.uc.edu> PR middle-end/13127 * tree-inline.c (declare_return_variable): Set the no warning bit on the variable created for the return value. 2004-02-06 Andrew Pinski <pinskia@physics.uc.edu> PR middle-end/13127 * gcc.dg/20040206-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.tree-ssa.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.1162&r2=1.1.2.1163 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-inline.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.26.2.80&r2=1.26.2.81 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.tree-ssa.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.162&r2=1.1.2.163 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20040206-1.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=NONE&r2=1.1.2.1
The uninitialized warning is fixed, the only warning left is the one referenced in 13000, the testcase has been xfailed for it.
Broken again.
Mine.
Since this broke again, my patch will not help anymore.
Still there...
Ian posted a patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg00957.html>.
Subject: Bug 13127 CVSROOT: /cvs/gcc Module name: gcc Changes by: ian@gcc.gnu.org 2005-01-17 17:12:31 Modified files: gcc : ChangeLog tree-inline.c Log message: PR middle-end/13127: * tree-inline.c (expand_call_inline): Set TREE_NO_WARNING on a variable set to the return value of the inlined function. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7152&r2=2.7153 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-inline.c.diff?cvsroot=gcc&r1=1.162&r2=1.163
Fixed.
Subject: Bug 13127 CVSROOT: /cvs/gcc Module name: gcc Changes by: ian@gcc.gnu.org 2005-01-17 17:17:02 Modified files: gcc/testsuite : ChangeLog gcc/testsuite/gcc.dg: 20040206-1.c Log message: PR middle-end/13127 * gcc.dg/20040206-1.c: Remove xfail on bogus warning which is no longer emitted. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4896&r2=1.4897 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20040206-1.c.diff?cvsroot=gcc&r1=1.3&r2=1.4