[Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function

giovannibajo at libero dot it gcc-bugzilla@gcc.gnu.org
Mon Oct 4 10:15:00 GMT 2004


------- Additional Comments From giovannibajo at libero dot it  2004-10-04 10:14 -------
Slightly reduced testcase:
--------------------------------------
struct B {
  virtual B *copy(void) = 0;
};


template <typename T>
void foo(void) {

  struct D : public B {
    B *copy(void) {
      return new D(*this);
    }
  };

  new D();
}

template void foo<void>(void);
--------------------------------------
ice.cc:17:   instantiated from here
ice.cc:11: internal compiler error: in find_function_data, at function.c:233

Now we get this message on mainline too.


(gdb) list
228
229       for (p = outer_function_chain; p; p = p->outer)
230         if (p->decl == decl)
231           return p;
232
233       gcc_unreachable ();
234     }
235
236     /* Save the current context for compilation of a nested function.
237        This is called from language-specific code.  The caller should use


(gdb) p decl
$2 = 0x402b6740
(gdb) pt
 <function_decl 0x402b6740 foo
    type <function_type 0x40231c3c
        type <void_type 0x4022fa6c void type_6 VOID
            align 8 symtab 0 alias set -1
            pointer_to_this <pointer_type 0x4022fae0>>
        type_6 QI
        size <integer_cst 0x4021e1c8 constant invariant 8>
        unit size <integer_cst 0x4021e1e0 constant invariant 1>
        align 8 symtab 0 alias set -1
        arg-types <tree_list 0x40232120 value <void_type 0x4022fa6c void>>>
    public static weak no-static-chain decl_1 decl_5 QI file ice.cc line 7
    result <result_decl 0x402b6c3c type <void_type 0x4022fa6c void>
        ignored VOID file ice.cc line 7
        align 8 context <function_decl 0x402b6740 foo>> initial <block 
0x402bd0d0>
    pending-inline-info 0x402be244 template-info 0x402b45a0
    saved-insns 0x4021ac00>

(gdb) bt
#0  fancy_abort (file=0x84c84b2 "../../gcc/gcc/function.c", line=233,
    function=0x84c849f "find_function_data") at ../../gcc/gcc/diagnostic.c:591
#1  0x0828c245 in find_function_data (decl=0x402b6740)
    at ../../gcc/gcc/function.c:233
#2  0x0828c266 in push_function_context_to (context=0x0)
    at ../../gcc/gcc/function.c:253
#3  0x080f03e5 in synthesize_method (fndecl=0x402b8658)
    at ../../gcc/gcc/cp/method.c:718
#4  0x080565e3 in build_over_call (cand=0x85e229c, flags=3)
    at ../../gcc/gcc/cp/call.c:4765
#5  0x080578e8 in build_new_method_call (instance=0x402bf440, fns=0x85e229c,
    args=0x402b9b88, conversion_path=0x40217980, flags=3)
    at ../../gcc/gcc/cp/call.c:5341
#6  0x080eb90e in build_new_1 (exp=0x4028f32c) at ../../gcc/gcc/cp/init.c:2061
#7  0x080eae74 in build_new (placement=0x0, type=0x402b6d98, nelts=0x14,
    init=0x402b6d98, use_global_new=0) at ../../gcc/gcc/cp/init.c:1675
#8  0x0808e804 in tsubst_copy_and_build (t=0x402b1af8, args=0x402b4900,
    complain=3, in_decl=0x402b61d0, function_p=0 '\0')
    at ../../gcc/gcc/cp/pt.c:8357
#9  0x0808d098 in tsubst_expr (t=0x402b1af8, args=0x402b4900, complain=3,
    in_decl=0x402b61d0) at ../../gcc/gcc/cp/pt.c:8082
#10 0x0808c387 in tsubst_expr (t=0x402b51e0, args=0x402b4900, complain=3,
    in_decl=0x402b61d0) at ../../gcc/gcc/cp/pt.c:7830
#11 0x0808be95 in tsubst_expr (t=0x402b0140, args=0x402b4900, complain=3,
    in_decl=0x402b61d0) at ../../gcc/gcc/cp/pt.c:7965
#12 0x0808be95 in tsubst_expr (t=0x402b0118, args=0x402b4900, complain=3,
    in_decl=0x402b61d0) at ../../gcc/gcc/cp/pt.c:7965
#13 0x08094cdd in instantiate_decl (d=0x402b70e8, defer_ok=0, undefined_ok=0)
    at ../../gcc/gcc/cp/pt.c:11200
#14 0x0809544b in instantiate_pending_templates (retries=1)
    at ../../gcc/gcc/cp/pt.c:11297
#15 0x080b6396 in cp_finish_file () at ../../gcc/gcc/cp/decl2.c:2788
#16 0x0813f396 in c_common_parse_file (set_yydebug=0)
    at ../../gcc/gcc/c-opts.c:1098
#17 0x083b6206 in compile_file () at ../../gcc/gcc/toplev.c:985
#18 0x083b78e5 in do_compile () at ../../gcc/gcc/toplev.c:2069
#19 0x083b7949 in toplev_main (argc=2, argv=0xbfffeb14)
    at ../../gcc/gcc/toplev.c:2101
#20 0x08148ba3 in main (argc=2, argv=0xbfffeb14) at ../../gcc/gcc/main.c:35


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2004-09-25 16:45:26         |2004-10-04 10:15:02
               date|                            |


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



More information about the Gcc-bugs mailing list