GDCC
GDCC copied to clipboard
Warning for use of unconditionally uninitialized objects
Code which reads an object which could not have been initialized prior to being read should issue a warning. Such as:
int i = i;
int i;
int j + i + 10;
int i;
if(i) {}
Tracking and warning for potentially uninitialized reads would be nice, but there would certainly be false positives. Still, if it proves reasonably simple, these should also issue a warning at high warn level:
int i;
if(cond())
i = 10;
int j = i * 7;
The following, however, should not issue any warning:
void *p = &p; // Valid and well-defined.
int i, k;
int j = cond();
if(j)
i = 10;
if(j)
k = i + 6; // Has the same condition as the initialization.
else
k = 42;
int i; // GDCC is not advanced enough to second-guess labels and goto usage.
label: if(i) {}