I know that local variables can have a "random" value if not set, but is it bad to set the first value of a local variable with a pointer? For instance:
void setValue(int* p_val)
{
*p_val = …;
}
int main(void)
{
int val;
setValue(&val);
printf("%d", val);
return 0;
}
If setValue sets and never reads the value of the reference variable. Splint warns me that val is "used before the definition", and I'm a little surprised by this warning, since I believe that val should be set before printf is executed, and val is used. Is the bus not advanced enough to recognize the link used to set the initial value?
source
share