Hi all,
I was sad to discover that the compiler does not warn here:
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.
Jordan
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.
FYI
$ 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)
Thanks,
Dmitry