This is the mail archive of the gcc@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]

GCC-3.0.3, const Compound Literal array and optimisations


  Hello,

 First the snipset:

[etienne@localhost]$ cat > bug.c
extern inline unsigned translate (unsigned val)
{ return ((const unsigned []) { 10, 11, 12, 13 })[val]; }
void fct (void) {}

[etienne@localhost]$ /home/etienne/projet/toolchain/bin/gcc -O2 -S bug.c -o
bug.S
[etienne@localhost gujin]$ cat bug.S
        .file   "bug.c"
        .data
        .align 4
.LC0:
        .long   10
        .long   11
        .long   12
        .long   13
        .text
        .align 16
.globl fct
        .type   fct,@function
fct:
        pushl   %ebp
        movl    %esp, %ebp
        popl    %ebp
        ret
.Lfe1:
        .size   fct,.Lfe1-fct
        .ident  "GCC: (GNU) 3.0.3"
[etienne@localhost]$

[etienne@localhost]$ /home/etienne/projet/toolchain/bin/gcc -v
Reading specs from
/home/etienne/projet/toolchain/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/specs
Configured with: ../configure --prefix=/home/etienne/projet/toolchain
--enable-languages=C
Thread model: single
gcc version 3.0.3
[etienne@localhost]$

  I have two problems:
  - This "Compound Literal" translating array is in the .data section,
  even with the "const" keyword. I would wait it in the .rodata
  section. I know about the change "const" -> "static const" for
  declaration of variables inside functions, but casting the array
  to "static const unsigned" would be too strange for me.
  - The translating array is not removed (like for instance unused strings)
  even when the inline function is not called.
  The translating array is removed with GCC-2.95.*.

  Etienne.

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com


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