inline function containing static array omitted from output assembler

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Tue Jul 2 06:16:00 GMT 2002


At 15:03 02.07.2002, Mark J Roberts wrote:
>/*
>
>Compile this source code as follows:
>
>         gcc -V 3.1 -Wall -fomit-frame-pointer -O2 -S bug.c
>
>And look at the (lack of) output:
>
>         .file   "bug.c"
>         .section        .rodata
>         .align 32
>         .type   table.0,@object
>         .size   table.0,1024
>table.0:
>         .zero   1024
>         .text
>         .align 2
>         .p2align 4,,15
>globl bug
>         .type   bug,@function
>bug:
>         subl    $44, %esp
>         .p2align 4,,15
>L2:
>         jmp     .L2
>Lfe1:
>         .size   bug,.Lfe1-bug
>         .ident  "GCC: (GNU) 3.1"
>
>Fun, huh? GCC works correctly if "table" is not declared static, or
>if round() is not inlined. Also I found that it was possible to
>provoke GCC into doing the right thing by tweaking code in bug().
>Adding asm("# COMMENT") statements and inserting printf calls could
>get it working, for example. GCC also works correctly at -O9, if
>bug() itself is inlined into main().
>
>I can reproduce this with the various 3.0.[1345] GCCs installed on
>my i386 Linux 2.4 box, but not with 2.95.2.

And? Where is the bug? GCC correctly optimizes away the body of a 
non-terminating loop cause is has no side-effects. Or are you complaining 
about the body not always being optimized away?

Franz.



More information about the Gcc-bugs mailing list