This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I've found what I consider to be a nefarious deficiency in the C++ compiler - especially since I have recently spent over a day looking for a particular bug I composed. The problem with the compiler is illustrated by the following test case:
int TestCase (void)
{ int uninitialized_1;
int uninitialized_2;
for (int i=0; i<1; i++)
{ uninitialized_1++;
}
uninitialized_2 += 1;
return uninitialized_1 + uninitialized_2;
}
For the above code, the compiler warns that the variable 'uninitialized_2' is used before its value is set, but does not provide a similar warning for the variable 'uninitialized_1'. The lack of warning seems to be related to the variable residing within the loop body. If one simply comments the for-loop declaration (as below), the compiler correctly emits a pair of warnings, one for each of the uninitialized variables. Does anyone know if this behavior been fixed in a later version of the tool-set?
int TestCase (void)
{ int uninitialized_1;
int uninitialized_2;
//for (int i=0; i<1; i++)
{ uninitialized_1++;
}
uninitialized_2 += 1;
return uninitialized_1 + uninitialized_2;
}