From 70cdce4f3070899e0844fa8ed44afbea70561aac Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Sat, 1 Dec 2018 21:53:07 +0000 Subject: [PATCH] re PR c++/87523 (ICE: Closures apparently fail to capture constexpr) PR c++/87523 * g++.dg/cpp1y/lambda-generic-87523.C: New test. From-SVN: r266714 --- gcc/testsuite/ChangeLog | 3 ++ .../g++.dg/cpp1y/lambda-generic-87523.C | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-87523.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9dfc58d4d68..2cdbba498b7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -40,6 +40,9 @@ PR c++/79629 * g++.dg/other/error35.C: New test. + PR c++/87523 + * g++.dg/cpp1y/lambda-generic-87523.C: New test. + 2018-12-01 Jeff Law * gcc.dg/predict-22.c: Update expected output. diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-87523.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-87523.C new file mode 100644 index 00000000000..ecba1cfc322 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-87523.C @@ -0,0 +1,32 @@ +// PR c++/87523 +// { dg-do compile { target c++14 } } + +template +struct my_integer_constant { + constexpr my_integer_constant() {} + constexpr operator T() const { return v; } + constexpr T operator()() const { return v; } +}; + +template +struct constant_call { + template + static void call(T v, Callback f) { + char dummy[sizeof...(u)] = { ( (v == u) ? (f(my_integer_constant{}), static_cast(0)) : static_cast(0))... }; + (void)dummy; + } +}; + +void f(bool reverse_in, bool other_bool_in) { + auto helper = [&] (auto reverse_t) { + bool constexpr reverse_v = reverse_t; + (void)reverse_v; + constant_call::call(other_bool_in, + [&] (auto newb) { + bool reverse_v_dyn = reverse_v; + }); + }; + constant_call::call(reverse_in, [&] (auto reverse_t) { + helper(reverse_t); + }); +} -- 2.30.2