This is happening in one of my C projects.
#define total 400
unsigned long values[total];
Initially the entire values array is initialised to 0xffffffff and then it is filled with some valid values. There is a use case where the entire array is filled with valid entries. In that case, i see a crash and when i tried printing i value, it is going beyond total(400).
//Crashing, i value goes beyond 400
for (i = 0; ((values[i] != 0xffffffff) && (i < total)); i++)
{
// some processing code
}
But if i just swap the condition it works fine, it doesn't go beyond total.
//Working fine
for (i = 0; ((i < total) && (values[i] != 0xffffffff)); i++)
{
// some processing code
}
Anyone has seen this kind of behaviour. Please shed some light if you have faced this