Examples of errors detected by the V698 diagnostic
V698. Functions of strcmp() kind can return any values, not only -1, 0, or 1.
.NET CoreCLR
V698 Expression 'memcmp(....) == -1' is incorrect. This function can return not only the value '-1', but any negative value. Consider using 'memcmp(....) < 0' instead. sos util.cpp 142
bool operator( )(const GUID& _Key1, const GUID& _Key2) const
{ return memcmp(&_Key1, &_Key2, sizeof(GUID)) == -1; }
In cases like this, you should check one of the three states: '< 0', '0', or '> 0'.
Source Engine SDK
V698 Expression 'stricmp(....) == -1' is incorrect. This function can return not only the value '-1', but any negative value. Consider using 'stricmp(....) < 0' instead. utlintrusivelist.h 509
template <class T> void AddSortedByName(T * & head, T * node)
{
if ((!head) || (stricmp(node->m_Name, head->m_Name) == -1))
{
....
}
....
}