diff --git a/lib/checkother.cpp b/lib/checkother.cpp index dfd9a5b63..c82a96023 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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) { diff --git a/test/testother.cpp b/test/testother.cpp index 208bac521..6bf57ad9e 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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() {