commit 05beed857dc4e01061a38b764c26f1ff857788dd
Author: Jason Merrill <jason@redhat.com>
Date: Fri Dec 12 10:43:59 2014 -0500
PR c++/61402
* lambda.c (add_capture): Don't pass a dependent type to
variably_modified_type_p.
@@ -483,7 +483,8 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
NULL_TREE, array_type_nelts (type));
type = vla_capture_type (type);
}
- else if (variably_modified_type_p (type, NULL_TREE))
+ else if (!dependent_type_p (type)
+ && variably_modified_type_p (type, NULL_TREE))
{
error ("capture of variable-size type %qT that is not an N3639 array "
"of runtime bound", type);
new file mode 100644
@@ -0,0 +1,20 @@
+// PR c++/61402
+// { dg-do run { target c++14 } }
+
+extern "C" void abort();
+
+template<typename T>
+void foo(T t) {
+ auto test = [ i = ++t ](T v) {
+ if (i != v)
+ abort();
+ };
+ test(t);
+}
+
+int main(){
+ foo(3.14f);
+ foo(0);
+ foo('a');
+ foo(false);
+}