Fixed #6446 (FP zerodivcond on double arithmetics)

This commit is contained in:
Daniel Marjamäki 2015-03-03 15:50:31 +01:00
parent 925f077b8a
commit 6646a896f9
2 changed files with 3 additions and 3 deletions

View File

@ -1798,7 +1798,7 @@ void CheckOther::checkZeroDivision()
continue;
}
zerodivError(tok,false);
} else if (Token::Match(tok, "[/%]") && tok->astOperand2()) {
} else if (Token::Match(tok, "[/%]") && tok->astOperand2() && !astIsFloat(tok,false)) {
// Value flow..
const ValueFlow::Value *value = tok->astOperand2()->getValue(0LL);
if (value) {

View File

@ -265,11 +265,11 @@ private:
}
void zeroDiv1() {
void zeroDiv1() { // floating point division by zero => no error
check("void foo() {\n"
" cout << 1. / 0;\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (error) Division by zero.\n", errout.str());
ASSERT_EQUALS("", errout.str());
}
void zeroDiv2() {