From 8bca3f592cd3eca48afd88939160b2ebae8e47e5 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 4 Oct 2017 08:34:40 +0000 Subject: [PATCH] re PR c++/78816 ([c++14] Static auto variable usage in generic/variadic lambda fails to compile) 2017-10-04 Paolo Carlini PR c++/78816 * g++.dg/cpp1y/lambda-generic-variadic6.C: New. From-SVN: r253397 --- gcc/testsuite/ChangeLog | 5 +++++ .../g++.dg/cpp1y/lambda-generic-variadic6.C | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic6.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 816646517ac..192fac794c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-04 Paolo Carlini + + PR c++/78816 + * g++.dg/cpp1y/lambda-generic-variadic6.C: New. + 2017-10-04 Jakub Jelinek 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 index 00000000000..d6672a4f086 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic6.C @@ -0,0 +1,19 @@ +// PR c++/78816 +// { dg-do compile { target c++14 } } + +void f(void (*f1)(int)) { + f1(42); +} + +template +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){})); +} -- 2.30.2