From d276da0cf5bff87311330b395d3918b569bbbcc3 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 20 Jun 2017 12:47:17 -0400 Subject: [PATCH] PR c++/80972 - C++17 ICE with attribute packed. * call.c (build_over_call): Allow a TARGET_EXPR from reference binding. From-SVN: r249420 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/call.c | 2 ++ gcc/testsuite/g++.dg/ext/packed12.C | 6 ++++++ 3 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/packed12.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5786cbaea2a..01230c09f02 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-06-20 Jason Merrill + + 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 * cp-tree.h (CPTI_NELTS_IDENTIFIER): Delete. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d1f27dde830..b56da353519 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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 index 00000000000..2ad14de102d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/packed12.C @@ -0,0 +1,6 @@ +// PR c++/80972 + +struct A { int i; }; +struct B { A a; } __attribute__((packed)); + +A a = B().a;