+2018-04-09 Jason Merrill <jason@redhat.com>
+
+ PR c++/85256 - ICE capturing pointer to VLA.
+ * lambda.c (add_capture): Distinguish between variable-size and
+ variably-modified types.
+
2018-04-06 Jason Merrill <jason@redhat.com>
PR c++/85214 - ICE with alias, generic lambda, constexpr if.
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 "
+ sorry ("capture of variably-modified type %qT that is not an N3639 array "
"of runtime bound", type);
if (TREE_CODE (type) == ARRAY_TYPE
&& variably_modified_type_p (TREE_TYPE (type), NULL_TREE))
inform (input_location, "because the array element type %qT has "
"variable size", TREE_TYPE (type));
- type = error_mark_node;
+ return error_mark_node;
}
else
{
int m = 1;
int d[n][m];
[&]() {
- return d[1]; // { dg-error "variabl" }
+ return d[1]; // { dg-prune-output "sorry" }
}();
}
--- /dev/null
+// PR c++/85256
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Wno-vla }
+
+void foo(int i)
+{
+ int (*x)[i];
+ [=]{ [=]{ 0 ? x : x; }; }; // { dg-bogus "sorry" "" { xfail *-*-* } }
+
+}
{
int x[1][argc];
- [&x](int i) { // { dg-error "variable.size" }
- x[0][i] = 0; // { dg-prune-output "assignment" }
+ [&x](int i) { // { dg-prune-output "sorry" }
+ x[0][i] = 0; // { dg-prune-output "not captured" }
}(5);
}
fa[0][1]=1.8;
auto fx=[&](){
for(int c=0; c<2; c++){
- printf("use me", fa[0][c]); // { dg-error "capture of variable-size type" }
+ printf("use me", fa[0][c]); // { dg-prune-output "sorry" }
}
};
call(fx);