From b134cab0cfb4283b3b5581d81ae777d684af82a9 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 25 Sep 2019 13:53:04 +0000 Subject: [PATCH] PR c++/91877 - ICE with converting member of packed struct. * call.c (convert_like_real): Use similar_type_p in an assert. * g++.dg/conversion/packed1.C: New test. From-SVN: r276127 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 3 +-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/conversion/packed1.C | 12 ++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/conversion/packed1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ca317e7..1d30cef 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-09-25 Marek Polacek + + PR c++/91877 - ICE with converting member of packed struct. + * call.c (convert_like_real): Use similar_type_p in an assert. + 2019-09-25 Paolo Carlini * name-lookup.c (check_extern_c_conflict): Use DECL_SOURCE_LOCATION. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 77f10a9..45b984e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7382,8 +7382,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, tree type = TREE_TYPE (ref_type); cp_lvalue_kind lvalue = lvalue_kind (expr); - gcc_assert (same_type_ignoring_top_level_qualifiers_p - (type, next_conversion (convs)->type)); + gcc_assert (similar_type_p (type, next_conversion (convs)->type)); if (!CP_TYPE_CONST_NON_VOLATILE_P (type) && !TYPE_REF_IS_RVALUE (ref_type)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bf03a5e..8830baa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-25 Marek Polacek + + PR c++/91877 - ICE with converting member of packed struct. + * g++.dg/conversion/packed1.C: New test. + 2019-09-25 Richard Biener PR tree-optimization/91896 diff --git a/gcc/testsuite/g++.dg/conversion/packed1.C b/gcc/testsuite/g++.dg/conversion/packed1.C new file mode 100644 index 0000000..c4be930 --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/packed1.C @@ -0,0 +1,12 @@ +// PR c++/91877 - ICE with converting member of packed struct. +// { dg-do compile { target c++11 } } +// { dg-options "-fpack-struct" } + +template class b { +public: + b(const a &); +}; +struct { + int *c; +} d; +void e() { b(d.c); } -- 2.7.4