Reputation: 14081
I see the following Cppcheck
, but do not understand why I am getting it:
directoryutils.cpp 173 error returnReference false Reference to auto variable returned.
Neither I understand why an auto
variable would be returned, nor the "reference part". Is that a false positive?
header: static const FilePerApplication &applicationDataDirectoryMapWithoutCurrentVersion();
const CDirectoryUtils::FilePerApplication &CDirectoryUtils::applicationDataDirectoryMapWithoutCurrentVersion()
{
static const FilePerApplication dirs = [ = ] {
FilePerApplication directories;
for (const QFileInfo &info : CDirectoryUtils::applicationDataDirectories())
{
.... fill in data ....
directories.insert(info.filePath(), appInfo);
}
return directories; // LINE 173 why auto???
}();
return dirs;
}
using FilePerApplication = QMap<QString, CApplicationInfo>;
-> FilePerApplication
like here https://stackoverflow.com/a/9620143/356726 does not silence the check errorUpvotes: 2
Views: 526
Reputation: 411
The comment in Reason for failed Cppcheck "Reference to auto variable returned"? is most likely correct that it is about "automatic storage" and also it being a false positive related to incorrect handling of the lambda.
This error appeared in Cppcheck 1.48 and was fixed in version 1.54.
Upvotes: 1