seg violation of compiler - previous versions compiled ok!
Created attachment 16180 [details] the ii file the file you requested in your instructions on how to submit a bug report
Created attachment 16181 [details] unincluded testcase
Note, 4_1-branch is closed. I would suggest first trying a newer compiler on your code, e.g., 4.3.2.
Confirmed. Program received signal SIGSEGV, Segmentation fault. 0x0000000000cd5495 in strip_array_types (type=0x0) at /space/rguenther/src/svn/trunk/gcc/tree.c:5755 5755 while (TREE_CODE (type) == ARRAY_TYPE) (gdb) up #1 0x00000000005ad26d in cp_type_quals (type=0x0) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:7108 7108 type = strip_array_types (CONST_CAST_TREE(type)); (gdb) #2 0x0000000000585fb8 in original_type (t=0x0) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:236 236 int quals = cp_type_quals (t); (gdb) #3 0x0000000000589136 in merge_types (t1=0x7fd7237a0900, t2=0x0) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:602 602 if (original_type (t1) == original_type (t2)) (gdb) #4 0x00000000005895ee in merge_types (t1=0x7fd7237a0a80, t2=0x7fd723765a80) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:628 628 tree target = merge_types (TREE_TYPE (t1), TREE_TYPE (t2)); (gdb) call debug_tree (t1) <reference_type 0x7fd7237a0a80 type <template_type_parm 0x7fd7237a0900 T VOID align 8 symtab 0 alias set -1 canonical type 0x7fd7249b0f00 index 0 level 1 orig_level 1 reference_to_this <reference_type 0x7fd7237a0a80> chain <type_decl 0x7fd7237a09c0 T>> unsigned DI size <integer_cst 0x7fd7252fcb10 type <integer_type 0x7fd7253100c0 bit_size_type> constant 64> unit size <integer_cst 0x7fd7252fcb40 type <integer_type 0x7fd725310000 long unsigned int> constant 8> align 64 symtab 0 alias set -1 canonical type 0x7fd723fdf240> (gdb) call debug_tree (t2) <typename_type 0x7fd723765a80 reference type_0 type_6 VOID align 8 symtab 0 alias set -1 structural equality context <record_type 0x7fd72375d9c0 Cdeque> chain <type_decl 0x7fd723765b40 reference>> #0 0x0000000000cd5495 in strip_array_types (type=0x0) at /space/rguenther/src/svn/trunk/gcc/tree.c:5755 #1 0x00000000005ad26d in cp_type_quals (type=0x0) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:7108 #2 0x0000000000585fb8 in original_type (t=0x0) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:236 #3 0x0000000000589136 in merge_types (t1=0x7fd7237a0900, t2=0x0) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:602 #4 0x00000000005895ee in merge_types (t1=0x7fd7237a0a80, t2=0x7fd723765a80) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:628 #5 0x0000000000589d73 in merge_types (t1=0x7fd7237a0b40, t2=0x7fd72376c300) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:675 #6 0x000000000058a454 in merge_types (t1=0x7fd7237a0b40, t2=0x7fd72376c300) at /space/rguenther/src/svn/trunk/gcc/cp/typeck.c:723 #7 0x000000000042f5ca in duplicate_decls (newdecl=0x7fd72377b400, olddecl=0x7fd72376a500, newdecl_is_friend=0 '\0') at /space/rguenther/src/svn/trunk/gcc/cp/decl.c:1703 #8 0x000000000044cb25 in grokfndecl (ctype=0x7fd7237650c0, type=0x7fd7237a0cc0, declarator=0x7fd72530e780, parms=0x7fd72379e360, orig_declarator=0x7fd72530e780, virtualp=0, flags=NO_SPECIAL, quals=0, raises=0x0, check=1, friendp=0, publicp=1, inlinep=0, sfk=sfk_none, funcdef_flag=1 '\001', template_count=1, in_namespace=0x0, attrlist=0x7fff2d43db28) at /space/rguenther/src/svn/trunk/gcc/cp/decl.c:6802 #9 0x00000000004568e2 in grokdeclarator (declarator=0x1746bf0, declspecs=0x7fff2d43dd00, decl_context=NORMAL, initialized=1, attrlist=0x7fff2d43db28) at /space/rguenther/src/svn/trunk/gcc/cp/decl.c:9255 #10 0x000000000046900f in start_function (declspecs=0x7fff2d43dd00, declarator=0x1746c70, attrs=0x0) at /space/rguenther/src/svn/trunk/gcc/cp/decl.c:11698 #11 0x00000000005717a4 in cp_parser_function_definition_from_specifiers_and_declarator (parser=0x7fd724a137d0, decl_specifiers=0x7fff2d43dd00, attributes=0x0, declarator=0x1746c70) at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:17336 #12 0x0000000000568b31 in cp_parser_init_declarator (parser=0x7fd724a137d0, decl_specifiers=0x7fff2d43dd00, checks=0x0, function_definition_allowed_p=1 '\001', member_p=0 '\0', declares_class_or_enum=0, function_definition_p=0x7fff2d43dcff "\001") at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:12584 #13 0x00000000005721f8 in cp_parser_single_declaration (parser=0x7fd724a137d0, checks=0x0, member_p=0 '\0', explicit_specialization_p=0 '\0', friend_p=0x7fff2d43ddb7 "") at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:17682 #14 0x0000000000571b94 in cp_parser_template_declaration_after_export ( parser=0x7fd724a137d0, member_p=0 '\0') ---Type <return> to continue, or q <return> to quit--- at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:17535 #15 0x000000000056434a in cp_parser_template_declaration ( parser=0x7fd724a137d0, member_p=0 '\0') at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:9488 #16 0x00000000005624fd in cp_parser_declaration (parser=0x7fd724a137d0) at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:7884 #17 0x0000000000562298 in cp_parser_declaration_seq_opt (parser=0x7fd724a137d0) at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:7815 #18 0x0000000000567fd9 in cp_parser_namespace_body (parser=0x7fd724a137d0) at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:12028 #19 0x0000000000567f9f in cp_parser_namespace_definition ( parser=0x7fd724a137d0) at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:12007 #20 0x00000000005625c5 in cp_parser_declaration (parser=0x7fd724a137d0) at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:7912 #21 0x0000000000562298 in cp_parser_declaration_seq_opt (parser=0x7fd724a137d0) at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:7815 #22 0x000000000055ada9 in cp_parser_translation_unit (parser=0x7fd724a137d0) at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:3031 #23 0x000000000057bdfd in c_parse_file () at /space/rguenther/src/svn/trunk/gcc/cp/parser.c:21886
Reducing.
Thanks Richard.
Reduced testcase: template <typename T> class Cdeque { typedef T *pointer; class iterator { typedef typename Cdeque<T>::pointer pointer; pointer operator->(); }; }; template <typename T> T* Cdeque<T>::iterator::operator->() { }
Which I guess is invalid because the definition of Cdeque is not complete at the time we bind iterator::pointer to Cdeque<T>::pointer.
Though EDG accepts it (but of course nothing is instantiated here).
Subject: Re: [4.2/4.3/4.4 Regression] seg violation Hi, thanks for taking the time to look at my problem. I did try with version 4.2 and fared no better. Versions up to 4.0.x compile ok. Let me know if I can be of further assistance as I am quite stuck at the moment. Best regards, wdoeringer On Mon, 1 Sep 2008, rguenth at gcc dot gnu dot org wrote: > > > ------- Comment #9 from rguenth at gcc dot gnu dot org 2008-09-01 16:05 ------- > Though EDG accepts it (but of course nothing is instantiated here). > > >
Subject: Re: [4.2/4.3/4.4 Regression] seg violation Hi, I have added some substance to the reduced testcase, so that now actual code is generated. You find it in the attached file. It compiles well under g++ 4.0.1 (Apple Inc. Build 5456) but crashes under 4.2.1 (Ubuntu 4.2.1-5ubuntu4) and under 4.1.3 Best regards, wd.doeringer On Mon, 1 Sep 2008, rguenth at gcc dot gnu dot org wrote: > > > ------- Comment #9 from rguenth at gcc dot gnu dot org 2008-09-01 16:05 ------- > Though EDG accepts it (but of course nothing is instantiated here). > > >
Created attachment 16182 [details] test.cpp
Created attachment 16214 [details] very small testcase this is a ten-line testcase clearly pointing to a problem with type-resolution regards w.doeringer@fh-worms.de
Created attachment 16223 [details] compiler error on valid code might point to the problem causing the seg fault
The question remains if this is invalid or valid code.
(In reply to comment #8) > Which I guess is invalid because the definition of Cdeque is not complete > at the time we bind iterator::pointer to Cdeque<T>::pointer. This is not an issue because Cdeque<T>::pointer is a member of the current instantiation (per 14.6.2.1).
The failure happens because structural_comptypes calls resolve_typename_type, while merge_types does not. Maybe it should as in this patch? Index: ../../peak-gcc-src/gcc/cp/typeck.c =================================================================== --- ../../peak-gcc-src/gcc/cp/typeck.c (revision 143676) +++ ../../peak-gcc-src/gcc/cp/typeck.c (working copy) @@ -606,6 +606,11 @@ merge_types (tree t1, tree t2) if (TYPE_PTRMEMFUNC_P (t2)) t2 = TYPE_PTRMEMFUNC_FN_TYPE (t2); + if (TREE_CODE (t1) == TYPENAME_TYPE) + t1 = resolve_typename_type (t2, /*only_current_p=*/true); + if (TREE_CODE (t2) == TYPENAME_TYPE) + t2 = resolve_typename_type (t2, /*only_current_p=*/true); + code1 = TREE_CODE (t1); code2 = TREE_CODE (t2);
(In reply to comment #17) > + if (TREE_CODE (t1) == TYPENAME_TYPE) > + t1 = resolve_typename_type (t2, /*only_current_p=*/true); But I suppose you want consistently t1 here ;)
Test.cpp is a rejects-valid.
Subject: Bug 37314 Author: bonzini Date: Tue Feb 3 15:56:05 2009 New Revision: 143896 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143896 Log: gcc/cp: 2009-02-03 Paolo Bonzini <bonzini@gnu.org> PR c++/36897 * pt.c (convert_nontype_argument_function): Expect expr to be an ADDR_EXPR. PR c++/37314 * typeck.c (merge_types): Call resolve_typename_type if only one type is a typename. gcc/testsuite: 2009-02-03 Paolo Bonzini <bonzini@gnu.org> PR c++/36897 * g++.dg/template/func2.C: New test. PR c++/37314 * g++.dg/template/typename15.C: New. * g++.dg/template/typename16.C: New. Added: branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/func2.C branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typename15.C branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typename16.C Modified: branches/gcc-4_3-branch/gcc/cp/ChangeLog branches/gcc-4_3-branch/gcc/cp/pt.c branches/gcc-4_3-branch/gcc/cp/typeck.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
fixed on 4.3/4.4, still needs backporting to 4.2
Likewise... ;)
Subject: Bug 37314 Author: bonzini Date: Tue Feb 3 16:26:28 2009 New Revision: 143898 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143898 Log: gcc/cp: 2009-02-03 Paolo Bonzini <bonzini@gnu.org> PR c++/36897 * pt.c (convert_nontype_argument_function): Expect expr to be an ADDR_EXPR. PR c++/37314 * typeck.c (merge_types): Call resolve_typename_type if only one type is a typename. gcc/testsuite: 2009-02-03 Paolo Bonzini <bonzini@gnu.org> PR c++/36897 * g++.dg/template/func2.C: New test. PR c++/37314 * g++.dg/template/typename15.C: New. * g++.dg/template/typename16.C: New. Added: trunk/gcc/testsuite/g++.dg/template/func2.C - copied unchanged from r143896, branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/func2.C trunk/gcc/testsuite/g++.dg/template/typename15.C - copied unchanged from r143896, branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typename15.C trunk/gcc/testsuite/g++.dg/template/typename16.C - copied unchanged from r143896, branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typename16.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog
Closing 4.2 branch, fixed for 4.3.4 and 4.4.