When compiling the attached source code snippet test.cpp with the options -fno-unit-at-a-time and -finline-functions, erroneous code is produced in form of an infinite loop, see the attached disassembly file test.s. Use the following command line to reproduce the bug: powerpc-eabi-g++ -c -S -O2 -fno-unit-at-a-time -finline-functions -o test.s test.cpp A possible explanation for this bug may be that -fno-unit-at-a-time counteracts -finline-functions; -finline-functions needs the whole compilation unit or more while -finline-functions says don't use the whole compilation unit.
Created attachment 12979 [details] Source code snippet test.cpp
Created attachment 12980 [details] Disassembly output test.s
Can you try 4.0.x or 4.1.x as 3.4.x is no longer maintained?
(In reply to comment #3) > Can you try 4.0.x or 4.1.x as 3.4.x is no longer maintained? Unfortunately, our system is based on GCC 3.4.x and we cannot easily switch to GCC 4.x in a short timeframe.
Comment on attachment 12980 [details] Disassembly output test.s > .file "test.cpp" > .section ".text" > .align 2 > .globl _ZN5Actor17getResourceFacadeEv > .type _ZN5Actor17getResourceFacadeEv, @function >_ZN5Actor17getResourceFacadeEv: >.LFB2: > lwz 3,0(3) > blr >.LFE2: > .size _ZN5Actor17getResourceFacadeEv, .-_ZN5Actor17getResourceFacadeEv > .align 2 > .globl _ZN5Actor9configureEv > .type _ZN5Actor9configureEv, @function >_ZN5Actor9configureEv: >.LFB3: >.L3: > b .L3 <--------------------- ERROR: Infinite loop! >.LFE3: > .size _ZN5Actor9configureEv, .-_ZN5Actor9configureEv > .ident "GCC: (GNU) 3.4.4"
The bug has nothing to do with -fno-unit-at-a-time. (It is ignored for C++ anyways.) The bug is fixed since GCC 4.0.0. Btw, here's a shorter self-contained program that hangs when compiled with "g++ -O -finline-functions" by GCC 3.4.x: ==================================== struct A { virtual void FOO() {} }; struct B { A* p; B() : p(new A) {} A* foo(); void bar(); }; A* B::foo() { return p; } void B::bar() { foo()->FOO(); } int main() { B().bar(); return 0; } ====================================
Sorry, I wasn't quite right with my comment: The bug *is* related to -fno-unit-at-a-time. It is fixed, because the flag is ignored for C++ since GCC 4.0.0, i.e. the compiler now always uses the unit-at-a-time mode for C++.