http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59982

            Bug ID: 59982
           Summary: Loop optimizer generates an infinite loop
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ian at g0tcd dot com

Created attachment 31979
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31979&action=edit
Small source file exhibiting the problem

If a for loop has some sort of error check to break out of the loop, which
includes the loop control variable in the condition (e.g. as an array
subscript), then the proper loop termination condition is not evaluated which
can result in an infinite loop.

Version of gcc is a 4.8.1 cross-compiler targeting the Arm processor, hosted on
x86:

arm-ipa-linux-gnueabi-gcc (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The attached source code generates an infinite loop for the following
invocations:

arm-ipa-linux-gnueabi-gcc forLoop.c -o forLoop -O3
arm-ipa-linux-gnueabi-gcc forLoop.c -o forLoop -O2

These invocations produce correct code:
arm-ipa-linux-gnueabi-gcc forLoop.c -o forLoop
arm-ipa-linux-gnueabi-gcc forLoop.c -o forLoop -O1
arm-ipa-linux-gnueabi-gcc forLoop.c -o forLoop -O3
-fno-aggressive-loop-optimizations

Reply via email to