[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; } } }
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.
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.
An even shorter version: ============================================= void foo() { if (false) if (int i=0) int j=0; } =============================================
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
Only a 3.4 Regression now.
May we please have this patch committed to the 3.4 branch as well? Thanks!
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
Fixed.