no warning for arrays that are too short?

Hi all,

I was sad to discover that the compiler does not warn here:

If you want checking of array parameter bounds, you have to say "double arg[static 4]".

It's kind of bizarre, but I imagine it comes from people using array typedefs as parameters and C99 not wanting to mess with those.


Given that that’s a C-only feature, it wouldn’t seem unreasonable to also provide a warning for the non-static case (for use in C++). You can use ‘const double (&arg)[4]’ in C++, but that doesn’t allow arrays larger than 4 elements.


$ gcc -Wuninitialized -O a.c
a.c: In function 'main':
a.c:5:13: warning: '*((void *)&array+24)' is used uninitialized in
this function [-Wuninitialized]
a.c:10:14: note: 'array' was declared here

$ gcc --version
gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)