Bug 17518

Summary: [4.0 regression] Incorrect <var> is used uninitialized warning (-O1, -O2, -O3)
Product: gcc Reporter: Gerald Pfeifer <gerald>
Component: tree-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, pinskia, steven
Priority: P2 Keywords: diagnostic
Version: 4.0.0   
Target Milestone: 4.0.0   
Host: i686-pc-linux-gnu Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2004-09-16 10:37:38
Bug Depends on:    
Bug Blocks: 24639    

Description Gerald Pfeifer 2004-09-16 10:19:16 UTC
% cat x.c
main(int, char **) {
  bool b;
  if( false )
    if( b ) /* this never shall be reached */
      return -1;
}

% gccvs x.c -W -O1
x.c: In function `int main(int, char**)':
x.c:4: warning: 'b' is used uninitialized in this function
Comment 1 Andrew Pinski 2004-09-16 10:22:43 UTC
Hmm, I thought we ran cleanup_cfg before running warn_uninitialized.
Comment 2 Andrew Pinski 2004-09-16 10:37:38 UTC
Hmm, this is a very recent regression
: Search converges between 2004-09-12-trunk (#538) and 2004-09-14-trunk (#539).
Comment 3 Andrew Pinski 2004-10-12 13:10:13 UTC
Fixed by:
        * fold-const.c (fold_build_cleanup_point_expr): New function.
        * tree.h (fold_build_cleanup_point_expr): Prototype.


cp/ChangeLog:
        * semantics.c (maybe_cleanup_point_expr): Call
        fold_build_cleanup_point_expr.
        (maybe_cleanup_point_expr_void): New function.
        (add_decl_expr): Call maybe_cleanup_point_expr_void.
        (finish_expr_stmt): Likewise.
        (finish_return_stmt): Likewise.
        (finish_for_expr): Likewise.
        (finish_asm_stmt): Likewise.
        * typeck.c (condition_conversion): Call
        fold_build_cleanup_point_expr.
        
testsuite/ChangeLog:


        * g++.dg/init/for3.C: New test.
        * g++.dg/opt/switch2.C: New test.
        * g++.dg/warn/Wreturn-2.C: New test.