| 131 | } |
| 132 | |
| 133 | void 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 | //--------------------------------------------------------------------------- |
no test coverage detected