diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index b4d3e95bbd59d2b5920f270a22d57e1b426a8835..89df7d7600c732f52fc718330e8b70f20603d17a 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -9699,7 +9699,9 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
 		   (tmp, /*constexpr_context_p=*/true, flags))
 	    return false;
 	}
-      return RECUR (DECL_INITIAL (tmp), want_rval);
+      if (VAR_P (tmp))
+	return RECUR (DECL_INITIAL (tmp), want_rval);
+      return true;
 
     case TRY_FINALLY_EXPR:
       return (RECUR (TREE_OPERAND (t, 0), want_rval)
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr108606.C b/gcc/testsuite/g++.dg/cpp1y/pr108606.C
new file mode 100644
index 0000000000000000000000000000000000000000..71cfc679317ac23e8de0b927e2841b09236e12da
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr108606.C
@@ -0,0 +1,11 @@
+// PR c++/108606
+// { dg-do compile { target c++14 } }
+
+template <typename T>
+void bar (T) {}
+
+void
+foo ()
+{
+  bar ([&] (auto x) { class C { friend void baz (); }; });
+}