re PR c++/78816 ([c++14] Static auto variable usage in generic/variadic lambda fails...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 4 Oct 2017 08:34:40 +0000 (08:34 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 4 Oct 2017 08:34:40 +0000 (08:34 +0000)
2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/78816
* g++.dg/cpp1y/lambda-generic-variadic6.C: New.

From-SVN: r253397

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic6.C [new file with mode: 0644]

index 816646517ac1ef145fc28ff6bd21f8610ec1082a..192fac794c85307ef2dba5a39d3ce128e2d62e7b 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/78816
+       * g++.dg/cpp1y/lambda-generic-variadic6.C: New.
+
 2017-10-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/82374
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic6.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic6.C
new file mode 100644 (file)
index 0000000..d6672a4
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/78816
+// { dg-do compile { target c++14 } }
+
+void f(void (*f1)(int)) {
+  f1(42);
+}
+
+template <typename Lambda>
+static auto callback(Lambda &&l)
+{
+  static auto* p = &l;
+  p = &l;
+  return [](auto... x){ return (*p)(x...); };
+}
+
+int main() {
+  int x = 5;
+  f(callback([=](int y){}));
+}