https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79626
Bug ID: 79626 Summary: ICE on invalid code in build_temp (call.c:6489) Product: gcc Version: unknown Status: UNCONFIRMED Keywords: ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org Target Milestone: --- Reduced from a LLVM test-case, all releases I have are affected: $ cat /tmp/ice.C template <class a, class> struct b { b() b(b &) b(b< a, a > } void c(b< int, int >(b< int, int >()) ./xg++ -B. /tmp/ice.C /tmp/ice.C:2:12: error: expected ‘;’ at end of member declaration { b() b(b &) b(b< a, a > } ^ /tmp/ice.C:2:19: error: expected ‘;’ at end of member declaration { b() b(b &) b(b< a, a > } ^ /tmp/ice.C:2:33: error: expected ‘,’ or ‘...’ before ‘}’ token { b() b(b &) b(b< a, a > } ^ /tmp/ice.C:2:33: error: expected ‘)’ before ‘}’ token /tmp/ice.C:2:23: error: expected ‘;’ at end of member declaration { b() b(b &) b(b< a, a > } ^~~~~~~~~ /tmp/ice.C:2:34: error: expected ‘;’ after struct definition { b() b(b &) b(b< a, a > } ^ ; /tmp/ice.C:3:45: error: variable or field ‘c’ declared void void c(b< int, int >(b< int, int >()) ^ /tmp/ice.C: In instantiation of ‘struct b<int, int>’: /tmp/ice.C:3:44: required from here /tmp/ice.C:2:21: error: invalid constructor; you probably meant ‘b<int, int> (const b<int, int>&)’ { b() b(b &) b(b< a, a > } ^ xg++: internal compiler error: Segmentation fault (program cc1plus) It's a stack overflow: (gdb) bt #0 0x0000000000759282 in cp_build_qualified_type_real (type=0x7ffff6a06150, type_quals=0, complain=3) at ../../gcc/cp/tree.c:1121 #1 0x0000000000715976 in same_type_ignoring_top_level_qualifiers_p (type1=<optimized out>, type2=0x7ffff6a06150) at ../../gcc/cp/typeck.c:1465 #2 0x0000000000653a29 in is_properly_derived_from (derived=0x7ffff6a06150, base=0x7ffff6a06150) at ../../gcc/cp/call.c:8946 #3 0x00000000006547d6 in direct_reference_binding (type=type@entry=0x7ffff6a06738, conv=0x5d399d0) at ../../gcc/cp/call.c:1495 #4 0x000000000065a1d3 in reference_binding (rto=0x7ffff6a06738, rfrom=0x7ffff6a06150, expr=<optimized out>, c_cast_p=<optimized out>, flags=5, complain=2) at ../../gcc/cp/call.c:1627 #5 0x00000000006593ed in implicit_conversion (to=0x7ffff6a06738, from=0x7ffff6a06150, expr=0x7ffff6884118, c_cast_p=<optimized out>, flags=5, complain=2) at ../../gcc/cp/call.c:1837 #6 0x000000000065ab39 in add_function_candidate (candidates=candidates@entry=0x7ffffbfff368, fn=fn@entry=0x7ffff6a04900, ctype=ctype@entry=0x7ffff6a06150, first_arg=<optimized out>, args=0x7ffff5b469d8, access_path=access_path@entry=0x7ffff6a00a80, conversion_path=0x7ffff6a00a80, flags=5, complain=3) at ../../gcc/cp/call.c:2197 #7 0x000000000065ba40 in add_candidates (fns=0x7ffff69ff820, fns@entry=0x7ffff69ff860, first_arg=first_arg@entry=0x7ffff5b48100, args=args@entry=0x7ffff5b469d8, return_type=return_type@entry=0x0, explicit_targs=explicit_targs@entry=0x0, template_only=template_only@entry=false, conversion_path=0x7ffff6a00a80, access_path=0x7ffff6a00a80, flags=5, candidates=0x7ffffbfff368, complain=3) at ../../gcc/cp/call.c:5504 #8 0x000000000065c1e0 in build_new_method_call_1 (complain=3, fn_p=0x0, flags=5, conversion_path=0x7ffff6a00a80, args=0x7ffff5b48100, fns=0x7ffff69ff860, instance=0x7ffff5b48100) at ../../gcc/cp/call.c:8684 #9 build_new_method_call (instance=instance@entry=0x7ffff5b48100, fns=0x7ffff5b472a0, args=args@entry=0x7ffffbfff468, conversion_path=<optimized out>, flags=flags@entry=5, fn_p=fn_p@entry=0x0, complain=3) at ../../gcc/cp/call.c:8884 #10 0x0000000000655832 in build_special_member_call (instance=0x7ffff5b48100, instance@entry=0x0, name=0x7ffff6891de0, args=args@entry=0x7ffffbfff468, binfo=0x7ffff6a00a80, binfo@entry=0x7ffff6a06150, flags=flags@entry=5, complain=complain@entry=3) at ../../gcc/cp/call.c:8415 #11 0x0000000000656b5f in build_temp (complain=3, diagnostic_kind=<synthetic pointer>, flags=5, type=0x7ffff6a06150, expr=0x7ffff6884118) at ../../gcc/cp/call.c:6489 #12 convert_like_real (convs=0x5d39860, expr=expr@entry=0x7ffff6884118, fn=fn@entry=0x7ffff6a04700, argnum=argnum@entry=0, inner=inner@entry=0, issue_conversion_warnings=issue_conversion_warnings@entry=true, c_cast_p=false, complain=3) at ../../gcc/cp/call.c:6907 #13 0x000000000065d161 in build_over_call (cand=cand@entry=0x5d39890, flags=flags@entry=5, complain=complain@entry=3) at ../../gcc/cp/call.c:7841 #14 0x000000000065c3a7 in build_new_method_call_1 (complain=3, fn_p=0x0, flags=5, conversion_path=<optimized out>, args=0x7ffff5b480c0, fns=<optimized out>, instance=0x7ffff5b480c0) at ../../gcc/cp/call.c:8814 #15 build_new_method_call (instance=instance@entry=0x7ffff5b480c0, fns=0x7ffff5b47270, args=args@entry=0x7ffffbfff748, conversion_path=<optimized out>, flags=flags@entry=5, fn_p=fn_p@entry=0x0, complain=3) at ../../gcc/cp/call.c:8884 #16 0x0000000000655832 in build_special_member_call (instance=0x7ffff5b480c0, instance@entry=0x0, name=0x7ffff6891de0, args=args@entry=0x7ffffbfff748, binfo=0x7ffff6a00a80, binfo@entry=0x7ffff6a06150, flags=flags@entry=5, complain=complain@entry=3) at ../../gcc/cp/call.c:8415