User account creation filtered due to spam.

Bug 16036 - [4.0 regression] Spurious "may be used uninitialized in this function" warning
Summary: [4.0 regression] Spurious "may be used uninitialized in this function" warning
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Richard Henderson
Keywords: diagnostic
: 14564 (view as bug list)
Depends on:
Blocks: Wuninitialized 14564
  Show dependency treegraph
Reported: 2004-06-17 18:40 UTC by wanderer
Modified: 2005-11-02 19:17 UTC (History)
2 users (show)

See Also:
Host: i386-unknown-freebsd5.1
Target: i386-unknown-freebsd5.1
Build: i386-unknown-freebsd5.1
Known to work: 3.4.0
Known to fail: 4.0.0
Last reconfirmed: 2004-06-17 19:54:04

source code .cc file (190 bytes, text/plain)
2004-06-17 18:41 UTC, wanderer
preprocessed source code .ii file (80.40 KB, text/plain)
2004-06-17 18:41 UTC, wanderer

Note You need to log in before you can comment on or make changes to this bug.
Description wanderer 2004-06-17 18:40:20 UTC
Current CVS mainline G++ (3.5.0 20040617) generate warning 
with command line: g++ -O -Wuninitialized -funit-at-a-time -o test.o -c
but not generate with: g++ -O -Wuninitialized -o test.o -c 
for code:

int main() {
    std::ofstream out("test.log");
    if( return 1;
    return 1;
  return 0;
Comment 1 wanderer 2004-06-17 18:41:07 UTC
Created attachment 6547 [details]
source code .cc file
Comment 2 wanderer 2004-06-17 18:41:57 UTC
Created attachment 6548 [details]
preprocessed source code .ii file
Comment 3 wanderer 2004-06-17 18:46:46 UTC
Warning text for testcase: In function `int main()': warning: 'T.722' may be used uninitialized in this function
Comment 4 Wolfgang Bangerth 2004-06-17 19:27:17 UTC
Confirmed. Someone should try to generate a reduced testcase. 
Comment 5 Andrew Pinski 2004-06-17 19:47:10 UTC
Note -funit-at-a-time just caused more inlining so ..., there is another bug like this one too.  This is all 
exception related.
Comment 6 Wolfgang Bangerth 2004-06-17 19:54:04 UTC
Here is a small testcase, having a lot to do with virtual inheritance: 
struct VB { 
    int i; 
    virtual ~VB(); 
struct D : virtual VB { 
    bool fail() { return (i & 3) != 0; } 
int main() { 
  try { 
    D d; 
      return 1; 
  } catch(...) {}; 
  return 0; 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c -O2 -Wuninitialized  -c In function `int main()': warning: 'T.46' may be used uninitialized in this function 
This warning is a mainline regression. 
Comment 7 Andrew Pinski 2004-06-17 20:49:54 UTC
*** Bug 14564 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2004-06-17 20:51:21 UTC
Richard you said you will deal with PR 14564, the testcase here shows excatly the same problem, it 
comes from the fact that the uninitialized warnings do not take into account abornal edges in the CFG.
Comment 9 Richard Henderson 2004-06-18 02:14:57 UTC
We can't "just ignore" abnormal edges, as that would fail to identify places
where variables are *never* assigned.  There does, however, appear to be some
pessimization going on because of the abnormal edge.

The generated code is correct, in case anyone's wondering.  The value is only
uninitialized along a path that it won't be used.
Comment 10 CVS Commits 2004-06-19 05:39:20 UTC
Subject: Bug 16036

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	2004-06-19 05:39:15

Modified files:
	gcc            : ChangeLog gimple-low.c gimplify.c tree-cfg.c 

Log message:
	PR c++/16036
	* gimple-low.c (lower_function_body): Generate return statement for
	fall off the end of the function here ...
	* tree-cfg.c (make_edges): ... instead of here.
	* gimplify.c (gimplify_return_expr): Mark return temp TREE_NO_WARNING.


Comment 11 Richard Henderson 2004-06-19 05:42:27 UTC