diff --git a/cfg/std.cfg b/cfg/std.cfg index 8db8eb5d9..6d6966998 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -217,6 +217,7 @@ + 0.0: @@ -228,6 +229,7 @@ + 0.0: @@ -239,6 +241,7 @@ + 0.0: diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 84676ddf4..479262618 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -241,12 +241,6 @@ void CheckFunctions::checkMathFunctions() mathfunctionCallWarning(tok); // case log(0) } } - - // sqrt( x ): if x is negative the result is undefined - else if (Token::Match(tok, "sqrt|sqrtf|sqrtl ( %num% )")) { - if (MathLib::isNegative(tok->strAt(2))) - mathfunctionCallWarning(tok); - } // atan2 ( x , y): x and y can not be zero, because this is mathematically not defined else if (Token::Match(tok, "atan2|atan2f|atan2l ( %num% , %num% )")) { if (MathLib::isNullValue(tok->strAt(2)) && MathLib::isNullValue(tok->strAt(4))) diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index cdc6cacb0..80edccc02 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -455,9 +455,9 @@ private: " std::cout << sqrtf(-1) << std::endl;\n" " std::cout << sqrtl(-1) << std::endl;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (warning) Passing value -1 to sqrt() leads to implementation-defined result.\n" - "[test.cpp:4]: (warning) Passing value -1 to sqrtf() leads to implementation-defined result.\n" - "[test.cpp:5]: (warning) Passing value -1 to sqrtl() leads to implementation-defined result.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (error) Invalid sqrt() argument nr 1. The value is -1 but the valid values are '0.0:'.\n" + "[test.cpp:4]: (error) Invalid sqrtf() argument nr 1. The value is -1 but the valid values are '0.0:'.\n" + "[test.cpp:5]: (error) Invalid sqrtl() argument nr 1. The value is -1 but the valid values are '0.0:'.\n", errout.str()); // implementation-defined behaviour for "finite values of x<0" only: check("void foo()\n"