PR c++/91877 - ICE with converting member of packed struct.
authorMarek Polacek <polacek@redhat.com>
Wed, 25 Sep 2019 13:53:04 +0000 (13:53 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 25 Sep 2019 13:53:04 +0000 (13:53 +0000)
* 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
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/packed1.C [new file with mode: 0644]

index ca317e7730bea1ac9fca4d68f8594d53f22790db..1d30cef717e2b7170c2f89bd54546a198e663a38 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-25  Marek Polacek  <polacek@redhat.com>
+
+       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  <paolo.carlini@oracle.com>
 
        * name-lookup.c (check_extern_c_conflict): Use DECL_SOURCE_LOCATION.
index 77f10a9f5f1b7162f2924abaa80e11ff574bc5ac..45b984ecb1185497361d5a4e424ab0fc7b4f8230 100644 (file)
@@ -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))
              {
index bf03a5e3c9eea53435e40018532d92405e63db0e..8830baa3abaef06b8318eb67fd7c64d155600fd3 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-25  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/91877 - ICE with converting member of packed struct.
+       * g++.dg/conversion/packed1.C: New test.
+
 2019-09-25  Richard Biener  <rguenther@suse.de>
 
        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 (file)
index 0000000..c4be930
--- /dev/null
@@ -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 <typename a> class b {
+public:
+  b(const a &);
+};
+struct {
+  int *c;
+} d;
+void e() { b<const int *>(d.c); }