http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58391
Bug ID: 58391 Summary: avr-gcc: Certain functions with computed goto could be inlined Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: semicontinuity at yandex dot ru Certain functions with computed goto could be inlined. Currently, if a function contains computed goto it is not inlined. Here, the function and the address variable are static and function is called from one place only, so the compiler could have inlined the function, just like functions without computed goto. // --------------------------------------------------------------------- static void* address; static void test(void) { char flag = 1; goto *address; // address is computed properly beforehand (left out for brevity) for(;;) { asm volatile("nop\t\n"); flag = 0; L1: (void)&&L1; if (flag==0) { address = &&L1; return; } asm volatile("nop\t\n"); flag = 0; L2: (void)&&L2; if (flag==0) { address = &&L2; return; } } } int main(void) { for(;;) { test(); } return 0; } // --------------------------------------------------------------------- Compiling C: main.c avr-gcc -c -mmcu=atmega8535 -I. -gdwarf-2 -I../../bsp -I../../../.. -O3 -save-temps -v -ffixed-r2 -ffixed-r3 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=.obj/main.lst -std=gnu99 -Wundef -MD -MP -MF .dep/main.o.d main.c -o .obj/main.o Using built-in specs. COLLECT_GCC=avr-gcc Target: avr Configured with: ../../gcc.gnu.org/gcc-4_7-branch/configure --target=avr --prefix=/local/gnu/install/gcc-4.7-mingw32 --host=i386-mingw32 --build=i686-linux-gnu --enable-languages=c,c++ --disable-nls --disable-shared --with-dwarf2 --with-avrlibc=yes Thread model: single gcc version 4.7.2 (GCC)