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

Method checkCastIntToCharAndBackError

lib/checkother.cpp:133–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void CheckOtherImpl::checkCastIntToCharAndBackError(const Token *tok, const std::string &strFunctionName)
134{
135 reportError(
136 tok,
137 Severity::warning,
138 "checkCastIntToCharAndBack",
139 "$symbol:" + strFunctionName + "\n"
140 "Storing $symbol() return value in char variable and then comparing with EOF.\n"
141 "When saving $symbol() return value in char variable there is loss of precision. "
142 " When $symbol() returns EOF this value is truncated. Comparing the char "
143 "variable with EOF can have unexpected results. For instance a loop \"while (EOF != (c = $symbol());\" "
144 "loops forever on some compilers/platforms and on other compilers/platforms it will stop "
145 "when the file contains a matching character.", CWE197, Certainty::normal
146 );
147}
148
149
150//---------------------------------------------------------------------------

Callers 1

getErrorMessagesMethod · 0.80

Calls 1

reportErrorFunction · 0.70

Tested by

no test coverage detected