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]

[Bug c++/16681] New: array initialization in struct construct is a memory hog (only in gcc 3.3 and 3.4, older is fine)


This code compiles quickly and with little memory in gcc-2.95 through gcc-3.2
but in gcc-3.3 and gcc-3.4 it will take up to a gig and a half (or so) of memory
and take 2 minutes and 20 seconds to compile (vs .06 in earlier versions).

struct foo {
  unsigned char buffer[4111222];
  foo() 
    : buffer()
    {}
};

int main(void)
{

}

Here is my compiler information information (on the one system that could
compile the whole thing, also tried it with g++-2.95 g++-3.2 g++-3.3 and g++-3.4
on an up to date debian unstable machine):
[~]$ time g++ -v -save-temps -Wall foo.cpp
Reading specs from /usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --prefix=/usr/local/gcc-3.4.1
--enable-languages=c,c++
Thread model: posix
gcc version 3.4.1
 /usr/local/gcc-3.4.1/libexec/gcc/i686-pc-linux-gnu/3.4.1/cc1plus -E -quiet -v
-D_GNU_SOURCE foo.cpp -mtune=pentiumpro -Wall -o foo.ii
ignoring nonexistent directory
"/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1
 /usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/i686-pc-linux-gnu
 /usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward
 /usr/local/include
 /usr/local/gcc-3.4.1/include
 /usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/include
 /usr/include
End of search list.
 /usr/local/gcc-3.4.1/libexec/gcc/i686-pc-linux-gnu/3.4.1/cc1plus -fpreprocessed
foo.ii -quiet -dumpbase foo.cpp -mtune=pentiumpro -auxbase foo -Wall -version -o
foo.s
GNU C++ version 3.4.1 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 as --traditional-format -V -Qy -o foo.o foo.s
GNU assembler version 2.11.90.0.8 (i386-redhat-linux) using BFD version 2.11.90.0.8
 /usr/local/gcc-3.4.1/libexec/gcc/i686-pc-linux-gnu/3.4.1/collect2 -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o
/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/crtbegin.o
-L/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1
-L/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../.. foo.o -lstdc++
-lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/crtend.o /usr/lib/crtn.o

real    2m17.412s
user    2m14.220s
sys     0m3.140s

Thats a redhat 7.2 system but as I said above it happens on a debian-unstable
box too (it doesn't have enough memory to complete the compile, only 512 megs).

Here is the foo.ii:
# 1 "foo.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.cpp"
struct foo {
  unsigned char buffer[4111222];
  foo()
    : buffer()
    {}
};

int main(void)
{

}

Sorry if this isn't in the right format and let me know if anymore information
is needed, I read through the guidelines, looked at the frequently reported bugs
and searched but didn't find the bug.

-- 
           Summary: array initialization in struct construct is a memory hog
                    (only in gcc 3.3 and 3.4, older is fine)
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lafary at activmedia dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16681


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