https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87523
Bug ID: 87523 Summary: ICE: Closures apparently fail to capture constexpr Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: williamtnavarre at mail dot com Target Milestone: --- Possibly related to PR 86429? It's not exactly the same because in this test case there is a failure even though I'm not even demanding that the compiler necessarily consider the the captured variable constexpr. This is the full file below. No #include is required to observe the failing behavior. From g++ --version: g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 Command: g++ -std=c++17 inp.cpp === template <typename T, T v> struct my_integer_constant { constexpr my_integer_constant() {} constexpr operator T() const { return v; } constexpr T operator()() const { return v; } }; template <typename T, T... u> struct constant_call { template <typename Callback> static void call(T v, Callback f) { char dummy[sizeof...(u)] = { ( (v == u) ? (f(my_integer_constant<T, u>{}), static_cast<char>(0)) : static_cast<char>(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<bool, true, false>::call(other_bool_in, [&] (auto newb) { bool reverse_v_dyn = reverse_v; }); }; constant_call<bool, true, false>::call(reverse_in, [&] (auto reverse_t) { helper(reverse_t); }); } === Output includes: ./table/src/inp.cpp:23:57: internal compiler error: in tsubst_copy, at cp/pt.c:14588 bool reverse_v_dyn = reverse_v; ^~~~~~~~~~~~~