Patchwork C++ PATCH for c++/51416 (ICE on invalid auto)

login
register
mail settings
Submitter Jason Merrill
Date Dec. 17, 2011, 3:26 a.m.
Message ID <4EEC0BE7.3020602@redhat.com>
Download mbox | patch
Permalink /patch/131974/
State New
Headers show

Comments

Jason Merrill - Dec. 17, 2011, 3:26 a.m.
When there are no arguments for a parameter pack, an expansion between 
parens in a variable initializer reduces to value-initialization.  This 
isn't valid for auto.  Fixed by checking for incomplete type.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 380724b25cd317ea8b6434cdd1215e831ac2dcde
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Dec 16 18:31:01 2011 -0500

    	PR c++/51416
    	* init.c (build_value_init_noctor): Check for incomplete type.

diff --git a/gcc/testsuite/g++.dg/cpp0x/auto31.C b/gcc/testsuite/g++.dg/cpp0x/auto31.C
new file mode 100644
index 0000000..26a6560
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto31.C
@@ -0,0 +1,12 @@ 
+// PR c++/51416
+// { dg-do compile { target c++11 } }
+
+template<typename T, typename... U> void foo(T, U... u)
+{
+  auto foo(u...);		// { dg-error "auto" }
+}
+
+void bar()
+{
+  foo(0);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic103.C b/gcc/testsuite/g++.dg/cpp0x/variadic103.C
index 6d12331..9d6b5ea 100644
--- a/gcc/testsuite/g++.dg/cpp0x/variadic103.C
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic103.C
@@ -5,7 +5,7 @@  T&& create();
 
 template<class T, class... Args>
 void test() {
-  T t(create<Args>()...);	// { dg-error "unknown bound" }
+  T t(create<Args>()...);	// { dg-error "incomplete" }
   (void) t;
 }