I am facing scenario where rule 9.1 getting violated. I want to read an auto variable(having garbage value while declaring) before initialization and to assign null if it is not null. If it is null, then with different value. Sample code:
{
int8_t reg_num;
uint64_t var1[NUM];
for (reg_num = 0; reg_num < NUM; reg_num++) {
if (var1[reg_num] != VAR_NULL) {
var1 [reg_num] = VAR_NULL;
} else {
var1[reg_num] = func1();
}
}
}
Violation is for the line if (var1[reg_num] != VAR_NULL)
where var1[reg_num]
is reading before initialization.
Is there any way to write the same code without violating 9.1