From 091fe099ba9093b8577ad4a10b56e18c6ea3daea Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 25 Jan 2020 23:09:57 -0500 Subject: [PATCH] checking: avoid verify_type_variant crash on incomplete type. Here, we end up calling gen_type_die_with_usage for a type that's in the middle of finish_struct_1, after we set TYPE_NEEDS_CONSTRUCTING on it but before we copy all the flags to the variants--and, significantly, before we set its TYPE_SIZE. It seems reasonable to only look at TYPE_NEEDS_CONSTRUCTING on complete types, since we aren't going to try to create an object of an incomplete type any other way. PR c++/92601 * tree.c (verify_type_variant): Only verify TYPE_NEEDS_CONSTRUCTING of complete types. --- gcc/ChangeLog | 6 +++ gcc/testsuite/g++.dg/debug/verify1.C | 64 ++++++++++++++++++++++++++++ gcc/tree.c | 2 +- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/debug/verify1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4a30b936e71..e983d5233b1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-01-26 Jason Merrill + + PR c++/92601 + * tree.c (verify_type_variant): Only verify TYPE_NEEDS_CONSTRUCTING + of complete types. + 2020-01-26 Darius Galis * config/rx/rx.md (setmemsi): Added rx_allow_string_insns constraint diff --git a/gcc/testsuite/g++.dg/debug/verify1.C b/gcc/testsuite/g++.dg/debug/verify1.C new file mode 100644 index 00000000000..67e407251a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/verify1.C @@ -0,0 +1,64 @@ +// PR c++/92601 +// { dg-additional-options "-g -fchecking -std=c++17" } + +typedef int size_t; +template struct integral_constant { + static constexpr int value = __v; +}; +template struct A; +template using __remove_cv_t = typename A<_Tp>::type; +template +struct B : integral_constant {}; +template class tuple; +template struct A { + using type = tuple; +}; +template struct C { typedef __remove_cv_t __type; }; +template class D { +public: + typedef typename C<_Tp>::__type type; +}; +template struct enable_if; +template struct F {}; +template class G { +public: + int operator*(); + void operator++(); +}; +template +bool operator!=(G<_Iterator, _Container>, G<_Iterator, _Container>); +template class H; +template >> class vector { +public: + typedef G iterator; + iterator begin(); + iterator end(); +}; +template struct pack_c { typedef pack_c type; }; +template struct make_index_pack_join; +template +struct make_index_pack_join, pack_c> + : pack_c {}; +template +struct I + : make_index_pack_join::type, typename I::type> {}; +template <> struct I<1> : pack_c {}; +template +struct are_tuples_compatible_not_same + : F::type, int>::value> {}; +template struct tuple_impl; +template +struct tuple_impl, Ts...> { + template , UTuple>::value>::type> + tuple_impl(UTuple &&); +}; +template class tuple { + tuple_impl::type> _impl; + tuple(tuple &) = default; +}; +vector message_handler_registrations; +void fn1() { + for (auto t : message_handler_registrations) + ; +} diff --git a/gcc/tree.c b/gcc/tree.c index 0ddf002e9eb..298499fe876 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -13881,9 +13881,9 @@ verify_type_variant (const_tree t, tree tv) debug_tree (TYPE_SIZE_UNIT (t)); return false; } + verify_variant_match (TYPE_NEEDS_CONSTRUCTING); } verify_variant_match (TYPE_PRECISION); - verify_variant_match (TYPE_NEEDS_CONSTRUCTING); if (RECORD_OR_UNION_TYPE_P (t)) verify_variant_match (TYPE_TRANSPARENT_AGGR); else if (TREE_CODE (t) == ARRAY_TYPE) -- 2.30.2