[cfe-dev] warning request: partial array initialisation
Jay Foad
jay.foad at gmail.com
Tue Jun 19 01:20:51 PDT 2012
Hi,
I'd really like to be able to get a warning when "almost all" elements
of an array are initialised:
#define N 8
const int a[N] = { 3, 1, 4, 1, 5, 9, 2 };
warning: some but not all array elements initialised
This would be useful because we have a large codebase where N is
defined in some common header and there are lots of arrays of length N
scattered through the code. Occasionally someone increments N, but
forgets to update all the array initialisers (because it's hard to
find them).
I'm not sure what heuristics should be used to define "almost all".
Can clang or some static analyser already do this? "clang -Wall
-Wextra" doesn't seem to warn about it.
Thanks,
Jay.
More information about the cfe-dev
mailing list