From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14398 invoked by alias); 27 Jan 2005 19:59:32 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 14288 invoked by uid 48); 27 Jan 2005 19:59:25 -0000 Date: Thu, 27 Jan 2005 19:59:00 -0000 From: "kazu at cs dot umass dot edu" To: gcc-bugs@gcc.gnu.org Message-ID: <20050127195923.19659.kazu@cs.umass.edu> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug tree-optimization/19659] New: GCC does remove an "if" statement that never triggers. X-Bugzilla-Reason: CC X-SW-Source: 2005-01/txt/msg04076.txt.bz2 List-Id: extern void abort (void) __attribute__ ((__noreturn__)); /* Count up to *LENGTHP and then return 0. */ int foo (unsigned *lengthp) { unsigned index; for (index = 0; index != *lengthp; index++) { const unsigned *lengthp2 = lengthp; /* Note that this condition is never true. */ if (index >= *lengthp2) abort (); } return 0; } GCC does not remove the "if" statement even though it never triggers. Interestingly, if you remove "const" from the testcase above, GCC does remove the "if" statement. If you feed the testcase with "const" into GCC, CSE removes it. Hey, but isn't this a machine-independent optimization? -- Summary: GCC does remove an "if" statement that never triggers. Product: gcc Version: unknown Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kazu at cs dot umass dot edu CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19659