re PR c++/70971 (ICE in parameter pack expansion)
authorPaolo Carlini <paolo.carlini@oracle.com>
Sat, 28 Oct 2017 16:10:10 +0000 (16:10 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 28 Oct 2017 16:10:10 +0000 (16:10 +0000)
2017-10-28  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/70971
* g++.dg/torture/pr70971.C: New.

From-SVN: r254199

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

index 1646f4c..49693bc 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-28  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/70971
+       * g++.dg/torture/pr70971.C: New.
+
 2017-10-28  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/81758
diff --git a/gcc/testsuite/g++.dg/torture/pr70971.C b/gcc/testsuite/g++.dg/torture/pr70971.C
new file mode 100644 (file)
index 0000000..23f33aa
--- /dev/null
@@ -0,0 +1,48 @@
+// { dg-additional-options "-std=c++14" }
+
+template<typename Signature>
+class function;
+
+template<typename R, typename... Args>
+class invoker_base
+{
+ public:
+  virtual ~invoker_base() { }
+};
+
+template<typename F, typename R, typename... Args>
+class functor_invoker : public invoker_base<R, Args...>
+{
+ public:
+  explicit functor_invoker(const F& f) : f(f) { }
+ private:
+  F f;
+};
+
+template<typename R, typename... Args>
+class function<R (Args...)> {
+ public:
+  template<typename F>
+  function(const F& f) : invoker(0) {
+    invoker = new functor_invoker<F, R, Args...>(f); 
+  }
+  ~function() {
+    if (invoker)
+      delete invoker;
+  }
+ private:
+  invoker_base<R, Args...>* invoker;
+};
+
+template<typename>
+struct unique_ptr { };
+
+struct A {};
+template <class...> struct typelist {};
+template <class... Cs> unique_ptr<A> chooseB(typelist<Cs...>);
+template <class... Cs, class Idx, class... Rest>
+unique_ptr<A> chooseB(typelist<Cs...> choices, Idx, Rest... rest) {
+  auto f = [=](auto) { return [=] { return chooseB(choices, rest...); }; };
+  function<unique_ptr<A>()> fs[]{f(Cs{})...};
+}
+main() { chooseB(typelist<double, char>{}, 0, 1, 2); }