This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/26566] New: Invalid code: loop optimization removes exit condition
- From: "steffen dot list dot account at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Mar 2006 09:55:44 -0000
- Subject: [Bug c/26566] New: Invalid code: loop optimization removes exit condition
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
With -O2 or higher, the following little C loop does not terminate:
short i;
for (i=-1; i; i--) ;
The generated assembler code is:
.L2:
jmp .L2
which means that the exit condition has been completely eliminated.
The same loop works as expected (terminates after 0xffff iterations) with
gcc-4.0 or earlier, with -O1 or lower, and with unsigned types.
This is an i386 style system with a P4 2.8 GHz, running Debian SID/i386 with
gcc-4.1 1:4.1.0-0 from Debian experimental.
--
Summary: Invalid code: loop optimization removes exit condition
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: steffen dot list dot account at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26566