On 12/12/24 2:07 PM, Simon Martin wrote:
We currently ICE upon the following valid (under -Wno-vla) code

=== cut here ===
void f(int c) {
   constexpr int r = 4;
   [&](auto) { int t[r * c]; }(0);
}
=== cut here ===

The problem is that when parsing the lambda body, and more specifically
the multiplication, we mark the lambda as LAMBDA_EXPR_CAPTURE_OPTIMIZED
even though the replacement of r by 4 is "undone" by the call to
build_min_non_dep in build_x_binary_op. This makes prune_lambda_captures
remove the proxy declaration while it should not, and we trip on an
assert at instantiation time.

Why does prune_lambda_captures remove the declaration if it's still used in the function body? Setting LAMBDA_EXPR_CAPTURE_OPTIMIZED just means "we might have optimized away some captures", the tree walk should have found the use put back by build_x_binary_op.

Jason

Reply via email to