13574 – [3.3 Regression] array default initializer in class lets gcc consume all memory and die (original) (raw)

| Description Roland Pabel 2004-01-05 23:09:09 UTC When trying to compile this program --- class A { public: #ifdef SAFE A() : argc(0) { }; #else A() : argc(0), argv() { }; #endif private: int argc; char* argv[]; }; int main() { A y; } --- with g++ without -DSAFE, the compiler consumes all memory until it chokes: g++ argv.cpp -o argv -Wall virtual memory exhausted: Cannot allocate memory It does not happen when using "char**" as type. some info: uname -a Linux operator 2.4.20-4GB #1 Wed Oct 29 22:20:11 CET 2003 i686 i686 i386 GNU/Linux g++ -v Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.1/specs Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --disable-checking --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux Thread model: posix gcc version 3.3.1 (SuSE Linux) Comment 1 Drea Pinski 2004-01-05 23:45:35 UTC Confirmed a regression from 3.2.3, I am not going to run Phil's regression hunter on this because it would cause problems for Phil's machine. Comment 2 Drea Pinski 2004-01-10 22:11:30 UTC This should have been rejected just as ICC 6.0 (in strict ANSI mode only). Comment 3 Jan Hubicka 2004-01-10 22🔞37 UTC Note that the memory consumption happens while trying to intialize the array and taking (unsigned int)-1 as upper bound.#0 0x40093d45 in memset () from /lib/libc.so.6 #1 0x084f61a7 in ggc_alloc (size=67108852) at ../../gcc/ggc-page.c:1156 #2 0x0832ab45 in ggc_alloc_cleared (size=67108852) at ../../gcc/ggc-common.c:134 #3 0x0832abe2 in ggc_calloc (s1=16777213, s2=4) at ../../gcc/ggc-common.c:188 #4 0x085a12b9 in htab_expand (htab=0x40177780) at ../../libiberty/hashtab.c:393 #5 0x085a149d in htab_find_slot_with_hash (htab=0x40177780, element=0x5acac8fc, hash=140315878, insert=INSERT) at ../../libiberty/hashtab.c:510 #6 0x085a14cf in htab_find_slot (htab=0x40177780, element=0x5acac8fc, insert=INSERT) at ../../libiberty/hashtab.c:558 #7 0x082d294b in size_int_type_wide (number=6291408, type=0x401799b4) at ../../gcc/fold-const.c:1569 #8 0x082d1662 in int_const_binop (code=PLUS_EXPR, arg1=0x5acac8c0, arg2=0x4016d94c, notrunc=0) at ../../gcc/fold-const.c:1334 #9 0x082d2aa0 in size_binop (code=PLUS_EXPR, arg0=0x5acac8c0, arg1=0x4016d94c) at ../../gcc/fold-const.c:1609 #10 0x0815d7a0 in build_zero_init (type=0x4024372c, nelts=0x0, static_storage_p=false) at ../../gcc/cp/init.c:231 #11 0x0815d8dc in build_default_init (type=0x4024372c, nelts=0x0) at ../../gcc/cp/init.c:296 #12 0x0815dc81 in perform_member_init (member=0x40243798, init=0x0) at ../../gcc/cp/init.c:362 #13 0x0815ee30 in emit_mem_initializers (mem_inits=0x40238ed8) at ../../gcc/cp/init.c:694 #14 0x0817abe3 in finish_mem_initializers (mem_inits=0x40238e88) at ../../gcc/cp/semantics.c:1187 #15 0x08127ed8 in cp_parser_mem_initializer_list (parser=0x40242800) at ../../gcc/cp/parser.c:7063 #16 0x08127db7 in cp_parser_ctor_initializer_opt (parser=0x40242800) at ../../gcc/cp/parser.c:7020 #17 0x0812cdb5 in cp_parser_ctor_initializer_opt_and_function_body (parser=0x40242800) at ../../gcc/cp/parser.c:11183 #18 0x08131453 in cp_parser_function_definition_after_declarator (parser=0x40242800, inline_p=true) at ../../gcc/cp/parser.c:13989 #19 0x08132047 in cp_parser_late_parsing_for_member (parser=0x40242800, member_function=0x402433cc) at ../../gcc/cp/parser.c:14380 #20 0x0812db6b in cp_parser_class_specifier (parser=0x40242800) at ../../gcc/cp/parser.c:11650 #21 0x08129c5f in cp_parser_type_specifier (parser=0x40242800, flags=CP_PARSER_FLAGS_OPTIONAL, is_friend=false, is_declaration=true, declares_class_or_enum=0xbffff620, is_cv_qualifier=0xbffff61f) at ../../gcc/cp/parser.c:8541 #22 0x08127813 in cp_parser_decl_specifier_seq (parser=0x40242800, flags=CP_PARSER_FLAGS_OPTIONAL, attributes=0xbffff66c, declares_class_or_enum=0xbffff668) at ../../gcc/cp/parser.c:6652 #23 0x081274df in cp_parser_simple_declaration (parser=0x40242800, function_definition_allowed_p=true) at ../../gcc/cp/parser.c:6382 #24 0x081274ac in cp_parser_block_declaration (parser=0x40242800, statement_p=false) at ../../gcc/cp/parser.c:6342 #25 0x08127359 in cp_parser_declaration (parser=0x40242800) at ../../gcc/cp/parser.c:6262 #26 0x08127184 in cp_parser_declaration_seq_opt (parser=0x40242800) at ../../gcc/cp/parser.c:6171 #27 0x08122d82 in cp_parser_translation_unit (parser=0x40242800) at ../../gcc/cp/parser.c:2307 #28 0x0813315c in c_parse_file () at ../../gcc/cp/parser.c:15044 #29 0x081f4be8 in c_common_parse_file (set_yydebug=0) at ../../gcc/c-opts.c:1216 #30 0x084b9390 in compile_file () at ../../gcc/toplev.c:1804 #31 0x084be34e in do_compile () at ../../gcc/toplev.c:4611 #32 0x084be3e6 in toplev_main (argc=3, argv=0xbffff834) at ../../gcc/toplev.c:4651 #33 0x081f8fcf in main (argc=3, argv=0xbffff834) at ../../gcc/main.c:35 ibm:~ # Comment 5 Mark Mitchell 2004-01-16 19:28:39 UTC Fixed in GCC 3.4. Comment 7 Gabriel Dos Reis 2004-01-21 08:07:06 UTC Fixed with backport from 3.4.0 | | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |