I'm gettting this:
test_Database.c:3037:38: Array element fixed1ElemFields[0] used before
definition
An rvalue is used that may not be initialized to a value on some execution
path. (Use -usedef to inhibit warning)
The relevent code is (BTW, note the annoying use of casts to initialise values
of type dsdbm_fieldType_t (actually unsigned char i.e. 8 bit):
dsdbm_fieldType_t fieldSizes[] = { (dsdbm_fieldType_t)1,
(dsdbm_fieldType_t)5,
(dsdbm_fieldType_t)8,
(dsdbm_fieldType_t)9,
(dsdbm_fieldType_t)16,
(dsdbm_fieldType_t)17,
(dsdbm_fieldType_t)20,
(dsdbm_fieldType_t)32 };
....
/*@reldef@*/ dsdbm_identifier_t fixed1ElemFields[sizeof(fieldSizes) /
sizeof(*fieldSizes)];
for (.....)
{
for (sizeIndex = 0; sizeIndex < numFieldSizes ; ++sizeIndex)
{
for (.....)
{
for (.....)
{
for (.....)
{
if (expression)
{
fixed1ElemFields[sizeIndex] = fieldId;
}
}
}
}
}
}
... code that uses fixed1ElemFields[]
I can tell splint the for loops execute with +forloopexec but I can't tell it
that "expression" is guaranteed to be true at least once for each value of
sizeIndex which means the array is fully defined at the end of these loops.
I don't want to use -usedef everywhere I use the array following this.
I also don't want to pre-initialise the array as I would have to change the
initialiser each time I change fieldSizes[] (but it's probably my best bet
for now).
The question is why doesn't reldef work?
Thanks,
Simon