workaround apparent MSVC mis-optimization

MSVC appears to misapply the identity
"A + -A == 0" which is not true for
non-finite floating point values.
This commit is contained in:
Michael Davidsaver
2019-09-29 21:02:19 -07:00
parent 2f88b70f21
commit e83818b25e
2 changed files with 11 additions and 17 deletions
+2 -8
View File
@@ -612,18 +612,12 @@ MAIN(epicsCalcTest)
testExpr(0.0 + NaN);
testExpr(Inf + 0.0);
testExpr(Inf + Inf);
#if defined(_WIN64) && defined(_MSC_VER)
// only test CALC as MSVC seems to incorrectly evaluate this expression at compile time.
// see note in epicsMathTest
testCalc("Inf + -Inf", NaN);
#else
testExpr(Inf + -Inf);
#endif
testExpr(Inf + NaN);
testExpr(-Inf + 0.0);
#if defined(_WIN64) && defined(_MSC_VER)
testCalc("-Inf + Inf", NaN);
#else
testExpr(-Inf + Inf);
#endif
testExpr(-Inf + -Inf);
testExpr(-Inf + NaN);
testExpr(NaN + 0.0);
+9 -9
View File
@@ -32,23 +32,23 @@ MAIN(epicsMathTest)
testOk1(epicsINF > 0.0);
testOk1(epicsINF - epicsINF != 0.0);
#if defined(_WIN64) && defined(_MSC_VER)
testTodoBegin("Known failure on windows-x64");
#if defined(_MSC_VER)
testTodoBegin("Known failure on windows (MSVC optimizer bug?)");
#endif
testOk1(epicsINF + -epicsINF != 0.0);
testOk1(-epicsINF + epicsINF != 0.0);
#if defined(_WIN64) && defined(_MSC_VER)
#if defined(_MSC_VER)
testTodoEnd();
#endif
testOk1(isnan(epicsINF - epicsINF));
#if defined(_WIN64) && defined(_MSC_VER)
testTodoBegin("Known failure on windows-x64");
#if defined(_MSC_VER)
testTodoBegin("Known failure on windows (MSVC optimizer bug?)");
#endif
testOk1(isnan(epicsINF + -epicsINF));
testOk1(isnan(-epicsINF + epicsINF));
#if defined(_WIN64) && defined(_MSC_VER)
#if defined(_MSC_VER)
testTodoEnd();
#endif
@@ -62,12 +62,12 @@ MAIN(epicsMathTest)
testOk1(!(epicsNAN > epicsNAN));
testOk1(isnan(epicsNAN - epicsNAN));
#if defined(_WIN64) && defined(_MSC_VER)
testTodoBegin("Known failure on windows-x64");
#if defined(_MSC_VER)
testTodoBegin("Known failure on windows (MSVC optimizer bug?)");
#endif
testOk1(isnan(epicsNAN + -epicsNAN));
testOk1(isnan(-epicsNAN + epicsNAN));
#if defined(_WIN64) && defined(_MSC_VER)
#if defined(_MSC_VER)
testTodoEnd();
#endif