I get these error in PC-Lint (au-misra-cpp.lnt):
ConverterUtil.cpp(90): error 864: (Info -- Expression involving variable 'transformValue' possibly depends on order of evaluation [MISRA C++ Rule 5-2-10])
ConverterUtil.cpp(90): error 864: (Info -- Expression involving variable 'transformValue' possibly depends on order of evaluation [MISRA C++ Rule 5-2-10])
ConverterUtil.cpp(90): error 534: (Warning -- Ignoring return value of function 'std::transform(std::_String_iterator>>, std::_String_iterator>>, std::_String_iterator>>, int (*)(int))' (compare with line 998, file C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\algorithm) [MISRA C++ Rules 0-1-7 and 8-4-6], [MISRA C++ Rule 0-3-2])
On this code:
/**Conversion from std::string to bool*/
bool ConverterUtil::ConvertStdStringToBool(const std::string value)
{
std::string transformValue = value;
bool retValue = false;
std::transform(transformValue.begin(), transformValue.end(), transformValue.begin(), &::tolower);
if(transformValue == std::string(static_cast<const char *>("true")))
{
retValue = true;
}
return retValue;
}
I guessed it didn't like the fact that I use the same std::string as input and output in the transform, but using an other string as output gives the same error.
Is it possible to make the std::transform MISRA compliant?