https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103704
Bug ID: 103704 Summary: [12 Regression] ICE: tree check: expected class 'type', have 'exceptional' (tree_vec) in operand_equal_p, at fold-const.c:3011 Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: ice-on-valid-code, openmp Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: asolokha at gmx dot com Target Milestone: --- g++ 12.0.0 20211212 snapshot (g:0b52083ea2c2dd9897031fdc3802a68fd4aa45ef) ICEs when compiling the following testcase, reduced from test/OpenMP/distribute_ast_print.cpp from the clang 13.0.0 test suite, w/ -fopenmp: struct S { int a; typedef int type; }; template <typename T> class S7 : public T { protected: T a; public: S7() { #pragma omp target #pragma omp teams #pragma omp distribute private(a) for (int k = 0; k < 1; ++k) ; } }; struct S8 : public S7<S> { S8() : S7<S>() {} }; % g++-12.0.0 -fopenmp -c wrzv9p97.cpp wrzv9p97.cpp: In instantiation of 'S7<T>::S7(typename T::type) [with T = S; typename T::type = int]': wrzv9p97.cpp:22:22: required from here wrzv9p97.cpp:13:9: internal compiler error: tree check: expected class 'type', have 'exceptional' (tree_vec) in operand_equal_p, at fold-const.c:3011 13 | #pragma omp target | ^~~ 0x867963 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree.c:8752 0x78ad2a tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree.h:3564 0x78ad2a operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned int) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/fold-const.c:3011 0xe00d30 operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned int) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/fold-const.c:3970 0xe00d30 operand_compare::verify_hash_value(tree_node const*, tree_node const*, unsigned int, bool*) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/fold-const.c:3956 0xe00d30 operand_compare::verify_hash_value(tree_node const*, tree_node const*, unsigned int, bool*) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/fold-const.c:3948 0xe016d8 operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned int) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/fold-const.c:2965 0xe016d8 operand_equal_p(tree_node const*, tree_node const*, unsigned int) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/fold-const.c:3987 0xb89dee finish_omp_target_clauses_r /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/cp/semantics.c:9332 0x14820e2 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree.c:11084 0x14822fd walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree.c:11315 0x14823ce walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree.c:11199 0x14822fd walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree.c:11315 0x14855ea walk_tree_without_duplicates_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/tree.c:11341 0xb78ef5 finish_omp_target_clauses(unsigned int, tree_node*, tree_node**) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/cp/semantics.c:9431 0xb2e5a8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/cp/pt.c:18980 0xb2bd7b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/cp/pt.c:18582 0xb2c18a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/cp/pt.c:18211 0xb2c18a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/cp/pt.c:18225 0xb2bd7b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /var/tmp/portage/sys-devel/gcc-12.0.0_p20211212/work/gcc-12-20211212/gcc/cp/pt.c:18582