* pt.c (tsubst_copy) [VAR_DECL]: Register the dummy instantiation
before substituting its initializer.
From-SVN: r246289
+2017-03-20 Jason Merrill <jason@redhat.com>
+
+ PR c++/79640 - infinite recursion with generic lambda.
+ * pt.c (tsubst_copy) [VAR_DECL]: Register the dummy instantiation
+ before substituting its initializer.
+
2017-03-20 Marek Polacek <polacek@redhat.com>
Paolo Carlini <paolo.carlini@oracle.com>
local static or constant. Building a new VAR_DECL
should be OK in all those cases. */
r = tsubst_decl (t, args, complain);
+ if (local_specializations)
+ /* Avoid infinite recursion (79640). */
+ register_local_specialization (r, t);
if (decl_maybe_constant_var_p (r))
{
/* We can't call cp_finish_decl, so handle the
--- /dev/null
+// PR c++/79640
+// { dg-do compile { target c++14 } }
+
+template<typename F> void foo(F f)
+{
+ f(1);
+}
+
+template<int> void bar()
+{
+ const int i = i;
+ foo([] (auto) { sizeof(i); });
+}
+
+void baz() { bar<1>(); }