This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: inline function containing static array omitted from output assembler


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]