From: Paolo Carlini Date: Wed, 4 Mar 2015 10:20:23 +0000 (+0000) Subject: re PR c++/64227 (Forwarding an argument of a function template to a generic lambda... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=550671691ee841093b72631af3b4bcf7dbad68d6;p=gcc.git re PR c++/64227 (Forwarding an argument of a function template to a generic lambda causes a compiler crash) 2015-03-04 Paolo Carlini PR c++/64227 * g++.dg/cpp1y/lambda-generic-ice1.C: New. From-SVN: r221181 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a2dadbf9726..f3e7f882b90 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-03-04 Paolo Carlini + + PR c++/64227 + * g++.dg/cpp1y/lambda-generic-ice1.C: New. + 2015-03-04 James Greenhalgh * gcc.target/aarch64/atomic-comp-swap-release-acquire.c: Add diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice1.C new file mode 100644 index 00000000000..0e40e62b322 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice1.C @@ -0,0 +1,42 @@ +// PR c++/64227 +// { dg-do compile { target c++14 } } + +template +struct remove_reference +{ typedef T type; }; + +template +struct remove_reference +{ typedef T type; }; + +template +struct remove_reference +{ typedef T type; }; + +template +constexpr T&& +forward(typename remove_reference::type& t) noexcept +{ return static_cast(t); } + +template +constexpr T&& +forward(typename remove_reference::type&& t) noexcept +{ return static_cast(t); } + +template +auto greater_than(T&& t) +{ + return [val = forward(t)] (const auto& arg) { return arg > val; }; +} + +template +void g(Functor f) +{ + for (int i = 0; i < 100000; i++) + f(i); +} + +int main() +{ + g(greater_than(10)); +}