For bar I get the expected warning but not for foo. void bar(int x, char buf[x]); void foo(int x; char buf[x], int x); int main() { char buf[10]; bar(11, buf); foo(buf, 11); } https://godbolt.org/z/zhzr43c55
The master branch has been updated by Martin Uecker <uecker@gcc.gnu.org>: https://gcc.gnu.org/g:8d6bd830f5f9c939e8565c0341a0c6c588834484 commit r14-1304-g8d6bd830f5f9c939e8565c0341a0c6c588834484 Author: Martin Uecker <uecker@tugraz.at> Date: Fri May 26 11:19:01 2023 +0200 c: -Wstringop-overflow for parameters with forward-declared sizes Warnings from -Wstringop-overflow do not appear for parameters declared as VLAs when the bound refers to a parameter forward declaration. This is fixed by splitting the loop that passes through parameters into two, first only recording the positions of all possible size expressions and then processing the parameters. PR c/109970 gcc/c-family: * c-attribs.cc (build_attr_access_from_parms): Split loop to first record all parameters. gcc/testsuite: * gcc.dg/pr109970.c: New test.
fixed on trunk.