https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119019
Bug ID: 119019
Summary: -Wshadow false negative for function parameter (used
as array length expression) shadowing a global
variable
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: alx at kernel dot org
Target Milestone: ---
alx@debian:~/tmp$ cat f.c
extern int n;
void f(int a[n], int n);
alx@debian:~/tmp$ gcc -Wall -Wextra -Wshadow -S f.c
alx@debian:~/tmp$ clang -Weverything -Wno-vla -S f.c
alx@debian:~/tmp$
That program obviously has a bug. The number of elements of 'a' is intended to
be $2, but it is actually controlled by the global variable 'n'. I think
-Wshadow should diagnose this.