re PR c++/67411 (internal compiler error: in tsubst_copy, at cp/pt.c:13473)
authorJason Merrill <jason@redhat.com>
Sun, 20 Dec 2015 18:38:30 +0000 (13:38 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 20 Dec 2015 18:38:30 +0000 (13:38 -0500)
PR c++/67411

* decl2.c (decl_maybe_constant_var_p): A proxy isn't constant.

From-SVN: r231862

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/g++.dg/cpp1y/lambda-generic-const1.C [new file with mode: 0644]

index 9b8c2ffc6f49579e3219c69d1251236d4c6bfcac..40ae390507d9adb788bf88de16c953cba5749a94 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/67411
+       * decl2.c (decl_maybe_constant_var_p): A proxy isn't constant.
+
 2015-12-18  Patrick Palka  <ppalka@gcc.gnu.org>
 
        PR c++/68978
index 5ae6266c7e1703975aaee7d4eafcf5a4fa76eda5..1e4282a806701937f2d5c1b3ec91c1186918e1c1 100644 (file)
@@ -4222,6 +4222,9 @@ decl_maybe_constant_var_p (tree decl)
     return false;
   if (DECL_DECLARED_CONSTEXPR_P (decl))
     return true;
+  if (DECL_VALUE_EXPR (decl))
+    /* A proxy isn't constant.  */
+    return false;
   return (CP_TYPE_CONST_NON_VOLATILE_P (type)
          && INTEGRAL_OR_ENUMERATION_TYPE_P (type));
 }
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-const1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-const1.C
new file mode 100644 (file)
index 0000000..8b54578
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/67411
+// { dg-do compile { target c++14 } }
+
+template <class T>
+void f()
+{
+  int i = 42;
+  [x = i] {
+    [&](auto) {
+      [=] { return x; }();
+    }(1);
+  }();
+}
+
+int main()
+{
+  f<int>();
+}