diff mbox

C++ PATCH for c++/52743 (ICE with list-initialized array)

Message ID 4F746E0A.2000404@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 29, 2012, 2:13 p.m. UTC
List-initialization of an array of scalars is not considered a 
user-defined conversion, so we need to check for it specifically to 
avoid treating it as a standard conversion.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
diff mbox

Patch

commit efaacb4065cce51b7374c31ddfb4682a880cbfc5
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 29 09:41:23 2012 -0400

    	PR c++/52743
    	* call.c (compare_ics): Handle ck_aggr like ck_list.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 88733f5..3c3dabb 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7620,7 +7620,7 @@  compare_ics (conversion *ics1, conversion *ics2)
      Specifically, we need to do the reference binding comparison at the
      end of this function.  */
 
-  if (ics1->user_conv_p || ics1->kind == ck_list)
+  if (ics1->user_conv_p || ics1->kind == ck_list || ics1->kind == ck_aggr)
     {
       conversion *t1;
       conversion *t2;
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array3.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array3.C
new file mode 100644
index 0000000..1a94f4e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array3.C
@@ -0,0 +1,10 @@ 
+// PR c++/52743
+// { dg-do compile { target c++11 } }
+
+void composite (int const (&) [2]);
+void composite (int const (&) [3]);
+
+int main ()
+{
+  composite({0,1});		// { dg-error "ambiguous" }
+}