This is the mail archive of the gcc-patches@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] |
Hello. With the following invalid code, we currently have an ICE (stack trace at the very end of this mail). === cut here === template<int> struct A { static const int i=x, j, k; }; template<int N> const int A<N>::j = i; template<int N> const int A<N>::k = j; A<0> a; === cut here === The problem is that DECL_INITIAL for the declaration of j is NULL (because the declaration for i is not "initializer_constant_valid_p" in cp/typeck2.c:628, so DECL_INITIAL is not set), and yet in constant_value_1 we pass it to fold_non_dependent_expr, that dereferences it, hence the ICE. The attached patch fixes it by checking that DECL_INITIAL (decl) is not NULL before calling fold_non_dependent_expr in constant_value_1. This has been boostrapped (except for the error in libjava reported there: http://gcc.gnu.org/ml/java-patches/2006-q3/msg00268.html) and regtested on i686-pc-linux-gnu with no new failures. Is it OK? If so, could someone commit it for me please? Thanks in advance. Best regards, Simon :ADDPATCH c++: PS: Here's the stack trace we get without this patch: (gdb) r pr28284.cpp Starting program: /newdisk/data/dev/projects/gcc/build_bootstrap/gcc/cc1plus pr28284.cpp pr28284.cpp:5: error: 'x' was not declared in this scope Program received signal SIGSEGV, Segmentation fault. type_dependent_expression_p (expression=0x0) at ../../trunk/gcc/cp/pt.c:12741 12741 if (TREE_CODE (expression) == IDENTIFIER_NODE) (gdb) bt #0 type_dependent_expression_p (expression=0x0) at ../../trunk/gcc/cp/pt.c:12741 #1 0x080a4048 in fold_non_dependent_expr (expr=0x0) at ../../trunk/gcc/cp/pt.c:3374 #2 0x081214c7 in constant_value_1 (decl=0x40171210, integral_p=0 '\0') at ../../trunk/gcc/cp/init.c:1473 #3 0x08053836 in convert_like_real (convs=0x87f55b8, expr=0x40171210, fn=0x0, argnum=0, inner=1, issue_conversion_warnings=0 '\0', c_cast_p=0 '\0') at ../../trunk/gcc/cp/call.c:4336 #4 0x08053917 in convert_like_real (convs=0x87f55d0, expr=0x40171210, fn=0x0, argnum=0, inner=0, issue_conversion_warnings=1 '\001', c_cast_p=0 '\0') at ../../trunk/gcc/cp/call.c:4349 #5 0x0805428b in perform_implicit_conversion (type=0x40179284, expr=Variable "expr" is not available. ) at ../../trunk/gcc/cp/call.c:6423 #6 0x080b196a in digest_init (type=0x4021c4ac, init=0x40171210) at ../../trunk/gcc/cp/typeck2.c:731 #7 0x080b2c55 in store_init_value (decl=0x40171268, init=0x40171210) at ../../trunk/gcc/cp/typeck2.c:622 #8 0x0807a526 in check_initializer (decl=0x40171268, init=0x0, flags=8, cleanup=0xbffff088) at ../../trunk/gcc/cp/decl.c:4819 #9 0x0807af0a in cp_finish_decl (decl=0x40171268, init=0x40171210, init_const_expr_p=1 '\001', asmspec_tree=0x0, flags=8) at ../../trunk/gcc/cp/decl.c:5183 #10 0x080ee12d in cp_parser_init_declarator (parser=0x4021f23c, decl_specifiers=0xbffff138, checks=0x0, function_definition_allowed_p=1 '\001', member_p=0 '\0', declares_class_or_enum=Variable "declares_class_or_enum" is not available. ) at ../../trunk/gcc/cp/parser.c:11194 #11 0x080ee615 in cp_parser_single_declaration (parser=0x4021f23c, checks=0x0, member_p=0 '\0', friend_p=0xbffff1db "") at ../../trunk/gcc/cp/parser.c:15684 #12 0x080fb9b3 in cp_parser_template_declaration_after_export (parser=0x4021f23c, member_p=0 '\0') at ../../trunk/gcc/cp/parser.c:15543 #13 0x080fd759 in cp_parser_declaration (parser=0x4021f23c) at ../../trunk/gcc/cp/parser.c:7108 #14 0x080fdd9d in cp_parser_declaration_seq_opt (parser=0x4021f23c) at ../../trunk/gcc/cp/parser.c:7031 #15 0x080fe4a5 in c_parse_file () at ../../trunk/gcc/cp/parser.c:2755 #16 0x0819c79a in c_common_parse_file (set_yydebug=0) at ../../trunk/gcc/c-opts.c:1164 #17 0x084e545a in toplev_main (argc=2, argv=0xbffff3a4) at ../../trunk/gcc/toplev.c:999 #18 0x081ab53f in main (argc=0, argv=0x4017f000) at ../../trunk/gcc/main.c:35
Attachment:
pr28284.patch
Description: Text document
Attachment:
CL_28284
Description: Text document
Attachment:
CL_28284_testsuite
Description: Text document
Attachment:
pr28284.cpp
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |