Bug 14203 - [3.4 regression] ICE on warning about uninitialized variable
Summary: [3.4 regression] ICE on warning about uninitialized variable
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 3.4.0
: P2 critical
Target Milestone: 3.4.0
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2004-02-18 23:13 UTC by Debian GCC Maintainers
Modified: 2004-10-30 21:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3 tree-ssa
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-02-19 00:26:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2004-02-18 23:13:01 UTC
[forwarded from http://bugs.debian.org/233548]

with 3.4 CVS 20040215:

g++ -Wall bug-233548.cc
bug-233548.cc: In function `int main()':
bug-233548.cc:19: warning: unused variable 'dummy'
bug-233548.cc:26: internal compiler error: in make_decl_rtl, at varasm.c:752
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

namespace Data 
{ 
  class Dummy; 
} 
 
namespace 
{ 
  const bool g_bAlways = false; 
 
  Data::Dummy* getDummy(); 
}; 
 
int main() 
{ 
  int i; 
 
  if (g_bAlways) 
  { 
     if (Data::Dummy* dummy = getDummy()) 
     { 
        int bla(5); 
 
        i = bla; 
     } 
  } 
}
Comment 1 Wolfgang Bangerth 2004-02-19 00:26:06 UTC
Confirmed. Here's something a little smaller: 
----------------------- 
int* foo();  
const bool b = false; 
 
int main() {  
  int i;  
  
  if (b)  
    if (int* p = foo())  
      {  
        int bla; 
        i = 1;  
      } 
} 
------------------------ 
 
This is a regression on 3.4 and mainline against 3.3.3: 
deal.II/base> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc -Wall 
x.cc: In function `int main()': 
x.cc:10: warning: unused variable 'bla' 
x.cc:8: warning: unused variable 'p' 
x.cc:13: internal compiler error: in make_decl_rtl, at varasm.c:707 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
W. 
Comment 2 Andrew Pinski 2004-02-19 00:55:00 UTC
The problem is that the variable was not emitted into RTL so the variable does have not a DECL_RTL and 
calling make_decl_rtl on the decl will cause an ICE as the variable is an automatic variable.  Note this is 
fixed on the tree-ssa but having this warning being on the tree level and not the RTL level.
Comment 3 Volker Reichelt 2004-02-19 02:32:52 UTC
An even shorter version:

=============================================
void foo()
{
  if (false)
    if (int i=0)
      int j=0;
}
=============================================
Comment 4 GCC Commits 2004-02-29 14:07:49 UTC
Subject: Bug 14203

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	sayle@gcc.gnu.org	2004-02-29 14:07:44

Modified files:
	gcc            : ChangeLog function.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: Wunused-6.C 

Log message:
	2004-02-29  Waldek Hebisch  <hebisch@math.uni.wroc.pl>
	
	PR middle-end/14203
	* function.c (uninitialized_vars_warning): Use DECL_RTL_SET_P
	instead of testing whether DECL_RTL is not NULL.
	
	2004-02-29  Roger Sayle  <roger@eyesopen.com>
	
	PR middle-end/14203
	* g++.dg/warn/Wunused-6.C: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2967&r2=2.2968
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/function.c.diff?cvsroot=gcc&r1=1.498&r2=1.499
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3553&r2=1.3554
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wunused-6.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 Andrew Pinski 2004-02-29 16:14:58 UTC
Only a 3.4 Regression now.
Comment 6 Mark Mitchell 2004-03-01 06:48:59 UTC
May we please have this patch committed to the 3.4 branch as well?

Thanks!
Comment 7 GCC Commits 2004-03-06 02:32:13 UTC
Subject: Bug 14203

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	sayle@gcc.gnu.org	2004-03-06 02:32:07

Modified files:
	gcc            : ChangeLog function.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: Wunused-6.C 

Log message:
	2004-03-05  Waldek Hebisch  <hebisch@math.uni.wroc.pl>
	
	PR middle-end/14203
	* function.c (uninitialized_vars_warning): Use DECL_RTL_SET_P
	instead of testing whether DECL_RTL is not NULL.
	
	2004-03-05  Roger Sayle  <roger@eyesopen.com>
	
	* g++.dg/warn/Wunused-6.C: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.293&r2=2.2326.2.294
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/function.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.483.4.5&r2=1.483.4.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.122&r2=1.3389.2.123
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wunused-6.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1

Comment 8 Andrew Pinski 2004-03-06 03:28:36 UTC
Fixed.