http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60816
Bug ID: 60816 Summary: Optimzed arm code generates infinite loop via branch instruction branching to current program counter Product: gcc Version: 4.8.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: andrew.j.c.parker at gmail dot com Created attachment 32583 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32583&action=edit Zip file containing repro cpp, compiler output, preprocessed file and GCC build script The bug is with GCC 4.8.3 compiler for ARM bare metal. It has been produced on both: build=linux (ubuntu) host=Windows target=arm build=osx host=osx target=arm The source comes from https://launchpad.net/gcc-arm-embedded/+download, specifically the q1 release https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-src.tar.bz2. I have also reproduced it with the Android NDK r9 and the arm 4.8 toolchain. The bug isn't present in 4.7.4. Attached is a simple cpp file attached to reproduce bug. Command line is: gcc -c -O3 compiler_bug.cpp The unlinked object file exhibits the problem. The generated assembly for the main function is: 00000000 <main>: 0: eafffffe b 0 <main> There are some comments in the code about what changes you can make to "remove" the bug. Also attached is the compiler output and the preprocessed .ii file.