This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/60708 (ICE with array temporary)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 01 Apr 2014 15:13:35 -0400
- Subject: C++ PATCH for c++/60708 (ICE with array temporary)
- Authentication-results: sourceware.org; auth=none
We need to make sure that the type we're converting to has its TYPE_SIZE
set appropriately.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 4d056b7b21032f78270f6ae398c15508b5fae8b2
Author: Jason Merrill <jason@redhat.com>
Date: Tue Apr 1 14:31:35 2014 -0400
PR c++/60708
* call.c (build_array_conv): Call complete_type.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 877f6d9..ae0d4ff 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -948,6 +948,9 @@ build_array_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
bool user = false;
enum conversion_rank rank = cr_exact;
+ /* We might need to propagate the size from the element to the array. */
+ complete_type (type);
+
if (TYPE_DOMAIN (type)
&& !variably_modified_type_p (TYPE_DOMAIN (type), NULL_TREE))
{
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist82.C b/gcc/testsuite/g++.dg/cpp0x/initlist82.C
new file mode 100644
index 0000000..3b9ccad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist82.C
@@ -0,0 +1,20 @@
+// PR c++/60708
+// { dg-do compile { target c++11 } }
+
+template <class T, class U> struct mypair {
+ mypair(T, U) {}
+};
+
+template<typename T> struct S {
+ mypair<T *, int> get_pair() noexcept {
+ return mypair<T*,int>(nullptr, 0);
+ }
+};
+
+static void foo(const mypair<char *, int> (&a)[2]) noexcept { }
+
+int main()
+{
+ S<char> s;
+ foo({s.get_pair(), s.get_pair()});
+}