Commit ad09440a by Jason Merrill

PR c++/60855 - ICE with sizeof VLA capture.

For normal captures we usually look through them within unevaluated context,
but that doesn't work here; trying to take the sizeof of the array in the
enclosing scope tries and fails to evaluate a SAVE_EXPR from the enclosing
scope.

	* lambda.c (is_lambda_ignored_entity): Don't look past VLA capture.
parent 27626519
2020-01-21 Jason Merrill <jason@redhat.com> 2020-01-21 Jason Merrill <jason@redhat.com>
PR c++/60855 - ICE with sizeof VLA capture.
* lambda.c (is_lambda_ignored_entity): Don't look past VLA capture.
PR c++/90732 - ICE with VLA capture and generic lambda. PR c++/90732 - ICE with VLA capture and generic lambda.
* pt.c (tsubst_lambda_expr): Repeat add_capture for VLAs. * pt.c (tsubst_lambda_expr): Repeat add_capture for VLAs.
......
...@@ -1327,8 +1327,9 @@ lambda_static_thunk_p (tree fn) ...@@ -1327,8 +1327,9 @@ lambda_static_thunk_p (tree fn)
bool bool
is_lambda_ignored_entity (tree val) is_lambda_ignored_entity (tree val)
{ {
/* Look past normal capture proxies. */ /* Look past normal, non-VLA capture proxies. */
if (is_normal_capture_proxy (val)) if (is_normal_capture_proxy (val)
&& !variably_modified_type_p (TREE_TYPE (val), NULL_TREE))
return true; return true;
/* Always ignore lambda fields, their names are only for debugging. */ /* Always ignore lambda fields, their names are only for debugging. */
......
// PR c++/60855
// { dg-do compile { target c++11 } }
// { dg-additional-options "-Wno-vla" }
int main() {
unsigned count = 5;
bool array[count];
[&array] () {
array[0] = sizeof(array) > 5;
}();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment