This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21626] New: Do not create very big empty structure to initialise stack
- From: "etienne_lorrain at yahoo dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 May 2005 15:16:24 -0000
- Subject: [Bug c/21626] New: Do not create very big empty structure to initialise stack
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
etienne@cygne:~/projet/gujin$ cat tmp.c
typedef struct {
enum { INIT = 0 } mode;
unsigned very_big_array[4096];
struct short_struct { int a,b,c; } str[5];
} z_stream;
struct short_struct fct (unsigned val) {
z_stream gzlib = { .mode = INIT }; /* everything is null */
return gzlib.str[val];
}
etienne@cygne:~/projet/gujin$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.6/specs
Configured with: ../src/configure -v --enable-
languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --
mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-
dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-
zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-
debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.6 (Debian 1:3.3.6-5)
etienne@cygne:~/projet/gujin$ gcc -Os -c tmp.c -o tmp.o
etienne@cygne:~/projet/gujin$ size tmp.o
text data bss dec hex filename
71 0 0 71 47 tmp.o
etienne@cygne:~/projet/gujin$ ../toolchain-4.0/bin/gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/home/etienne/projet/toolchain --enable-
languages=c
Thread model: posix
gcc version 4.0.0
etienne@cygne:~/projet/gujin$ ../toolchain-4.0/bin/gcc -Os -c tmp.c -o tmp.o
etienne@cygne:~/projet/gujin$ size tmp.o
text data bss dec hex filename
16509 0 0 16509 407d tmp.o
etienne@cygne:~/projet/gujin$ ../toolchain-4.0/bin/gcc -Os -S tmp.c -o tmp.s
etienne@cygne:~/projet/gujin$ cat tmp.s
.file "tmp.c"
.section .rodata
.align 32
.type C.0.1145, @object
.size C.0.1145, 16448
C.0.1145:
.zero 16448
.text
.globl fct
.type fct, @function
fct:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $16448, %esp
pushl $16448
movl 8(%ebp), %ebx
pushl $C.0.1145
leal -16452(%ebp), %eax
pushl %eax
call memcpy
imull $12, 12(%ebp), %eax
pushl $12
leal -64(%eax,%ebp), %eax
pushl %eax
pushl %ebx
call memcpy
movl %ebx, %eax
movl -4(%ebp), %ebx
leave
ret $4
.size fct, .-fct
.ident "GCC: (GNU) 4.0.0"
.section .note.GNU-stack,"",@progbits
etienne@cygne:~/projet/gujin$
--
Summary: Do not create very big empty structure to initialise
stack
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: etienne_lorrain at yahoo dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21626