From: Paolo Carlini Date: Fri, 13 Oct 2017 17:38:50 +0000 (+0000) Subject: re PR c++/69078 ([C++14] function local static not initialized when only used in... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d7327979fe8bcfdee1a3bfa77068072dc6073991;p=gcc.git 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 --- 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); + }); +}