From: Paolo Carlini Date: Wed, 13 Sep 2017 18:18:48 +0000 (+0000) Subject: re PR c++/61362 (g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 does not compile lambda with... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=97e63e1272bf265d412d89ab8f8249e8d3a9f8b2;p=gcc.git re PR c++/61362 (g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 does not compile lambda with template) 2017-09-13 Paolo Carlini PR c++/61362 * g++.dg/cpp0x/lambda/lambda-ice19.C: New. * g++.dg/cpp0x/lambda/lambda-ice20.C: Likewise. From-SVN: r252724 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9493be90fa..71e2b363604 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-09-13 Paolo Carlini + + PR c++/61362 + * g++.dg/cpp0x/lambda/lambda-ice19.C: New. + * g++.dg/cpp0x/lambda/lambda-ice20.C: Likewise. + 2017-09-13 Steve Ellcey PR tree-optimization/80925 diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice19.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice19.C new file mode 100644 index 00000000000..9fb43cdb8b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice19.C @@ -0,0 +1,29 @@ +// PR c++/61362 +// { dg-do compile { target c++11 } } + +struct function { + template + function(F){} + + void operator()(...) {} +}; + +struct Node { + unsigned length; +}; + +template +class C { +public: + unsigned longest = 0; + function f = [this](N node) { + if(node->length > this->longest) this->longest = node->length; + }; +}; + +int main() { + Node n; + n.length = 5; + C c; + c.f(&n); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice20.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice20.C new file mode 100644 index 00000000000..ae1b61b1d2c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice20.C @@ -0,0 +1,11 @@ +// PR c++/61362 +// { dg-do compile { target c++11 } } + +template +struct S { + int f{[this](){return 42;}()}; +}; + +int main(){ + return S{}.f; // should be 42 +}