Hi, the following code doesn't compile. It's related to my PR 14203 (or from Debian BR #233548). GCC 3.4.1 works fine. André struct Dummy { void foo(); }; const bool g_bAlways = false; int main() { bool test; if (g_bAlways) { if (Dummy* dummy = 0) { if (!test) { int d; d = 1; } dummy->foo(); } } return 0; }
: Search converges between 2004-08-23-3.4 (#55) and 2004-08-24-3.4 (#56). Confirmed.
Here's something shorter. It also crashes gcc 3.4.0 and 3.4.1. ================================= void foo() { if (0) if (int* p = 0) int i=*p; } ================================= : Search converges between 2003-04-16-trunk (#231) and 2003-04-17-trunk (#232).
Roger, ii looks like your patch http://gcc.gnu.org/ml/gcc-cvs/2003-04/msg00812.html is responsible for the regression. Could you please have a look?
(In reply to comment #2) > Here's something shorter. It also crashes gcc 3.4.0 and 3.4.1. > > ================================= > void foo() > { > if (0) > if (int* p = 0) > int i=*p; > } Indeed, this looks very similar to your shorter version in PR 14203.
Here's a testcase that looks even more like PR 14203 (and there's no dereferencing of the null pointer - even if that was unreachable) =============================== void foo() { if (false) if (int i=0) int j=i; } ===============================
Postponed until GCC 3.4.4.
Testing a fix.
Recategorizing.
Subject: Bug 17827 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: ebotcazou@gcc.gnu.org 2004-12-07 07:54:00 Modified files: gcc : ChangeLog c-semantics.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/other: unreachable1.C Log message: PR middle-end/17827 * c-semantics.c (expand_unreachable_if_stmt): Invoke expand_cond on the condition. 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.723&r2=2.2326.2.724 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-semantics.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.74.4.3&r2=1.74.4.4 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.318&r2=1.3389.2.319 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/unreachable1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
See http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00407.html
*** Bug 20485 has been marked as a duplicate of this bug. ***