Examples of errors detected by the V698 diagnostic

V698. strcmp()-like functions can return not only the values -1, 0 and 1, but any values.


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'.

Bugs Found

Checked Projects
Collected Errors
14 469
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →