re PR c++/51878 (ICE or OOM with decltype + variadic templates + "indirect" function...
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 11 Oct 2012 23:37:48 +0000 (23:37 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 11 Oct 2012 23:37:48 +0000 (23:37 +0000)
2012-10-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51878
* g++.dg/cpp0x/decltype45.C: New.

From-SVN: r192381

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype45.C [new file with mode: 0644]

index ff44d480c9815be0ae25ca1939b48754d6e4fd9e..6923335fad2539f8be222b5c21ea118eb7b551e6 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51878
+       * g++.dg/cpp0x/decltype45.C: New.
+
 2012-10-11  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/54784
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype45.C b/gcc/testsuite/g++.dg/cpp0x/decltype45.C
new file mode 100644 (file)
index 0000000..f768d85
--- /dev/null
@@ -0,0 +1,40 @@
+// PR c++/51878
+// { dg-do compile { target c++11 } }
+
+template<class F, class... T>
+auto indirect_call(F f, T... t) -> decltype(f(t...))
+{
+  return f(t...);
+}
+
+template<class F, class T>
+struct VariadicBind
+{
+  F f;
+  T t;
+
+  template<class... A>
+  auto operator()(A... a) -> decltype(indirect_call(f, t, a...))
+  {
+    return indirect_call(f, t, a...);
+  }
+};
+
+template<class F>
+void apply(F f)
+{
+  f();
+}
+
+template<class F, class V1, class... V>
+void apply(F f, V1 v1, V... v)
+{
+  apply(VariadicBind<F, int>{f, v1}, v...);
+}
+
+void func(int, int) { }
+
+int main()
+{
+  apply(func, 0, 0);
+}