diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-09-27 15:39:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-28 10:11:00 +0200 |
commit | 928fc8d93960adedc1d9598aaa71eb1f23fce108 (patch) | |
tree | a9ea4ca109e0c84aff940693f8fade1d67831cfc /tests/auto/corelib/global/qnumeric | |
parent | a1521579983860f4f7b02d6eddc478448715ac0b (diff) |
Update the NaN tests to deal with non-conformance better
ICC apparently optimises 0 * anything directly to zero, even when it
should be doing a multiplication to conform to IEEE requirements. GCC in
fast-math mode does the same, but that also makes the rest of the
function unreliable, so we try to turn off fast-math mode if we can.
Task-number: QTBUG-22340
Change-Id: I0e3c5f4927b0a6bcb3189bb156c18843fc4b29b9
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'tests/auto/corelib/global/qnumeric')
-rw-r--r-- | tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 6646874d55..cdca851d85 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -87,24 +87,19 @@ void tst_QNumeric::fuzzyCompare() QCOMPARE(::qFuzzyCompare(-val2, -val1), isEqual); } +#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404) + // turn -ffast-math off +# pragma GCC optimize "no-fast-math" +#endif + void tst_QNumeric::qNan() { - double nan = qQNaN(); -#if defined( __INTEL_COMPILER) - QCOMPARE((0 > nan), false); - QCOMPARE((0 < nan), false); - QSKIP("This fails due to a bug in the Intel Compiler"); -#else - if (0 > nan) - QFAIL("compiler thinks 0 > nan"); - -# if defined(Q_CC_DIAB) - QWARN("!(0 < nan) would fail due to a bug in dcc"); -# else - if (0 < nan) - QFAIL("compiler thinks 0 < nan"); -# endif +#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ < 404) + QSKIP("Non-conformant fast math mode is enabled, cannot run test"); #endif + double nan = qQNaN(); + QVERIFY(!(0 > nan)); + QVERIFY(!(0 < nan)); QVERIFY(qIsNaN(nan)); QVERIFY(qIsNaN(nan + 1)); QVERIFY(qIsNaN(-nan)); @@ -115,7 +110,13 @@ void tst_QNumeric::qNan() QVERIFY(qIsInf(-inf)); QVERIFY(qIsInf(2*inf)); QCOMPARE(1/inf, 0.0); +#ifdef Q_CC_INTEL + QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); +#endif QVERIFY(qIsNaN(0*nan)); +#ifdef Q_CC_INTEL + QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); +#endif QVERIFY(qIsNaN(0*inf)); QVERIFY(qFuzzyCompare(1/inf, 0.0)); } |