I have an app that is near completion and am getting the following error whe running Analyze:
Assigned value is garbage or undefined
The error is occurring on this line of code:
float flowSourceValue = flowSource[count];
When running debugger, code DOES enter this for loop and floatSourceValue DOES get assigned.
if(gaugeReportsCFS){
count = 0;
gaugeCount = [flowKeys count];
float tally = 0.0;
float flowSource[gaugeCount];
for (NSString *key in flowKeys){
float flowSourceValue = flowSource[count]; //assigned value is garbage or undefined
if(flowSourceValue < 1){
gaugeReportsCFS = NO;
gaugeReportsFeet = YES;
} else {
if(!isnan(flowSource[count])){
flowSource[count] = [[rvrGauge.gaugeFlowList objectForKey:key] integerValue];
tally += flowSource[count];
}
}
count++;
}
}
What could be the reason I am getting this warning? Thanks!
The local array
float flowSource[gaugeCount];
Is not initialized and therefore can contain "garbage". Accessing it is undefined behavior.