This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/58636 (ICE with std::initializer_list<int&&>)


You can't form an array of references in C++, so we shouldn't consider a conversion to an initializer_list of references either.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.9.
commit 97303858558a5024b357e8ec6f4ffcf4f1c043fe
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Jul 13 11:53:10 2014 -0400

    	PR c++/58636
    	* call.c (build_list_conv): Don't try to build a list of references.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 4ca6be5..b16c6e4 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -806,6 +806,12 @@ build_list_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
   /* But no narrowing conversions.  */
   flags |= LOOKUP_NO_NARROWING;
 
+  /* Can't make an array of these types.  */
+  if (TREE_CODE (elttype) == REFERENCE_TYPE
+      || TREE_CODE (elttype) == FUNCTION_TYPE
+      || VOID_TYPE_P (elttype))
+    return NULL;
+
   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), i, val)
     {
       conversion *sub
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array4.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array4.C
new file mode 100644
index 0000000..af2045d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array4.C
@@ -0,0 +1,9 @@
+// PR c++/58636
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+// { dg-error "pointer to reference" "" { target *-*-* } 0 }
+int foo(std::initializer_list<int&&>);
+
+int i = foo({ 0 });		// { dg-error "std::initializer_list" }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]