MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / negativeBitwiseShiftError

Method negativeBitwiseShiftError

lib/checkother.cpp:3486–3495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3484
3485
3486void CheckOtherImpl::negativeBitwiseShiftError(const Token *tok, int op)
3487{
3488 if (op == 1)
3489 // LHS - this is used by intention in various software, if it
3490 // is used often in a project and works as expected then this is
3491 // a portability issue
3492 reportError(tok, Severity::portability, "shiftNegativeLHS", "Shifting a negative value is technically undefined behaviour", CWE758, Certainty::normal);
3493 else // RHS
3494 reportError(tok, Severity::error, "shiftNegative", "Shifting by a negative value is undefined behaviour", CWE758, Certainty::normal);
3495}
3496
3497//---------------------------------------------------------------------------
3498// Check for incompletely filled buffers.

Callers 1

getErrorMessagesMethod · 0.80

Calls 1

reportErrorFunction · 0.70

Tested by

no test coverage detected