This may be slightly off topic but I don't remember seeing this warning until these betas of 1.58 so I suspect this warning is due to the newer compiler. Problem is, it makes no sense at all.
Here is the code in question:
Code:
void DeviceManager::handleTick()
{
double currVal = 0.0;
for (std::vector<StatusEntry>::iterator it = statusEntries.begin(); it != statusEntries.end(); ++it)
{
currVal = it->getValueAsDouble();
if ( fabs(currVal - it->lastValue) > 0.001) //has the value changed?
{
Logger::avalanche("Value of %s has changed", it->statusName.c_str());
dispatchToObservers(*it);
it->lastValue = currVal;
}
}
}
So, basically I'm just using an iterator to go through a bunch of entries and seeing if they have changed since the last update cycle. The warning I get is:
Code:
/home/collin/projects/GEVCU7/src/DeviceManager.cpp:239:27: warning: 'out' may be used uninitialized in this function [-Wmaybe-uninitialized]
239 | if ( fabs(currVal - it->lastValue) > 0.001) //has the value changed?
| ~~~~~~~~^~~~~~~~~~~~~~~
In this case, you can see that line 239 is the line with fabs. The problem is, as you can see, there IS NO VARIABLE NAMED "out". There isn't a variable named out in the entire source file. I don't think there is a variable named out anywhere in the entire code base. Am I blind? Is this a compiler bug? Is there some valid explanation for this behavior? I really don't think that turning off this warning is appropriate. It's certainly a useful warning to have. But, I don't understand how this makes any sense.