From d7327979fe8bcfdee1a3bfa77068072dc6073991 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 13 Oct 2017 17:38:50 +0000 Subject: [PATCH] re PR c++/69078 ([C++14] function local static not initialized when only used in a generic/variadic lambda) 2017-10-13 Paolo Carlini PR c++/69078 * g++.dg/cpp1y/lambda-generic-69078-1.C: New. * g++.dg/cpp1y/lambda-generic-69078-2.C: Likewise. From-SVN: r253736 --- gcc/testsuite/ChangeLog | 6 ++++ .../g++.dg/cpp1y/lambda-generic-69078-1.C | 28 +++++++++++++++++++ .../g++.dg/cpp1y/lambda-generic-69078-2.C | 21 ++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-1.C create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-2.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d23143ad496..589dda59fc6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-10-13 Paolo Carlini + + PR c++/69078 + * g++.dg/cpp1y/lambda-generic-69078-1.C: New. + * g++.dg/cpp1y/lambda-generic-69078-2.C: Likewise. + 2017-10-13 Jakub Jelinek PR target/82274 diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-1.C new file mode 100644 index 00000000000..dc045c72065 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-1.C @@ -0,0 +1,28 @@ +// PR c++/69078 +// { dg-do run { target c++14 } } +// { dg-options "-Wall" } + +#include + +struct Class { + Class(void (*_param)()) : data(_param) {} + void (*data)(); +}; + +void funUser(void (*test)(int)) { + test(60); +} + +void user(Class& c, int i) { + (void)i; + assert (c.data); +} + +void probe() {} + +int main() { + static Class instance = { probe }; + funUser([](auto... p) { + user(instance, p...); + }); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-2.C new file mode 100644 index 00000000000..318e0967250 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-2.C @@ -0,0 +1,21 @@ +// PR c++/69078 +// { dg-do run { target c++14 } } + +#include + +template +void run( F &&f ) { + f(nullptr); +} + +struct V { + int i; +}; + +int main() { + static V const s={2}; + assert (s.i == 2); + run([](auto){ + assert (s.i == 2); + }); +} -- 2.30.2