https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106052

            Bug ID: 106052
           Summary: ICE with -Wmismatched-tags with partially specialized
                    friend struct of self type
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: beardsley.matt.j at gmail dot com
  Target Milestone: ---

The following uses gcc built from a fresh repo that I just cloned earlier today
(default build settings)

tmp.cpp:
    template <typename T1, typename T2>
    struct S {
        template <typename, typename>
        struct S2;

        template <typename Type>
        struct S2<Type, bool> {};

        friend struct S2<S<T1, T2>, bool>;
    };


No ICE with warning off:
$ g++ -c tmp.cpp -o /dev/null -Wno-mismatched-tags
(no output)

ICE with warning on:
$ g++ -c tmp.cpp -o /dev/null -Wmismatched-tags
tmp.cpp: In substitution of ‘template<class Type> struct S<T1, T2>::S2<Type,
bool> [with Type = S<T1, T2>]’:
tmp.cpp:10:2:   required from here
tmp.cpp:10:2: internal compiler error: tree check: accessed elt 2 of ‘tree_vec’
with 1 elts in tsubst, at cp/pt.cc:15831
   10 | };
      |  ^
0x8ae378 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        ../.././gcc/tree.cc:9016
0x9d5d11 tree_vec_elt_check(tree_node*, int, char const*, int, char const*)
        ../.././gcc/tree.h:3737
0xb71967 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../.././gcc/cp/pt.cc:15831
0xb7ff0e tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ../.././gcc/cp/pt.cc:13580
0xb80132 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ../.././gcc/cp/pt.cc:13562
0xb6eca7 get_partial_spec_bindings
        ../.././gcc/cp/pt.cc:25457
0xb6f15b most_specialized_partial_spec(tree_node*, int)
        ../.././gcc/cp/pt.cc:25703
0xaf2970 specialization_of
        ../.././gcc/cp/parser.cc:33627
0xaf2970 class_decl_loc_t::diag_mismatched_tags(tree_node*)
        ../.././gcc/cp/parser.cc:33811
0xaf8db8 class_decl_loc_t::diag_mismatched_tags()
        ../.././gcc/cp/parser.cc:33935
0xb3c292 c_parse_file()
        ../.././gcc/cp/parser.cc:48376
0xc721d1 c_common_parse_file()
        ../.././gcc/c-family/c-opts.cc:1235
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to