On Sat, 30 May 2026, Martin Uecker wrote:

> Bootstrapped and regression tested on x86_64.
> 
>     c: fix false positive for -Wvla-parameter [PR98539]
>     
>     In case of VLAs tat are multi-dimensional arrays with unspecified sizes,
>     the test in the warning code did not work correctly.  Fix this by
>     explicitely checking that there are specified or unspecified size
>     expressions to determine the presence of a VLA.
>     
>             PR c/98539
>     
>     gcc/c-family/ChangeLog:
>             * c-warn.cc (warn_parm_array_mismatch): Check number of size
>             expressions.
>     
>     gcc/testsuite/ChangeLog:
>             + gcc.dg/pr98539.c: New test.

OK, but with a note about pre-existing code being moved:

> +  if (newa->internal_p)
> +    newbnds = newa->vla_bounds (&newunspec) + newunspec;
> +
> +  unsigned curbnds = 0;
> +  unsigned curunspec = 0;
> +
> +  if (cura->internal_p)
> +    curbnds = cura->vla_bounds (&curunspec) + curunspec;

I think both these expressions calling vla_bounds are suspect, because 
vla_bounds modifies the object pointed to by its argument, and even after 
the C++17 changes to expression sequencing (and we don't require C++17 
yet), the operands of '+' aren't sequenced with respect to each other.

-- 
Joseph S. Myers
[email protected]

Reply via email to