PR c++/80972 - C++17 ICE with attribute packed.
authorJason Merrill <jason@redhat.com>
Tue, 20 Jun 2017 16:47:17 +0000 (12:47 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 20 Jun 2017 16:47:17 +0000 (12:47 -0400)
* call.c (build_over_call): Allow a TARGET_EXPR from reference
binding.

From-SVN: r249420

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/ext/packed12.C [new file with mode: 0644]

index 5786cbaea2a707d6036f001d88ee7c1fb30eb1ac..01230c09f021cadc9e0c84d51cff9ba506368b1f 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/80972 - C++17 ICE with attribute packed.
+       * call.c (build_over_call): Allow a TARGET_EXPR from reference
+       binding.
+
 2017-06-20  Nathan Sidwell  <nathan@acm.org>
 
        * cp-tree.h (CPTI_NELTS_IDENTIFIER): Delete.
index d1f27dde830c123c5b0a60900c7979972f9bfb6f..b56da353519ccae02f2ca76ef07f5bd16a155e19 100644 (file)
@@ -8025,6 +8025,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
         subobject.  */
       if (CHECKING_P && cxx_dialect >= cxx1z)
        gcc_assert (TREE_CODE (arg) != TARGET_EXPR
+                   /* It's from binding the ref parm to a packed field. */
+                   || convs[0]->need_temporary_p
                    || seen_error ()
                    /* See unsafe_copy_elision_p.  */
                    || DECL_BASE_CONSTRUCTOR_P (fn));
diff --git a/gcc/testsuite/g++.dg/ext/packed12.C b/gcc/testsuite/g++.dg/ext/packed12.C
new file mode 100644 (file)
index 0000000..2ad14de
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/80972
+
+struct A { int i; };
+struct B { A a; } __attribute__((packed));
+
+A a = B().a;