From: Wolfgang Bangerth Date: Wed, 29 Jul 2015 16:31:44 +0000 (-0500) Subject: Disable floating point exceptions for tests that specifically test is_nan. X-Git-Tag: v8.4.0-rc2~587^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b71401e1f843658cf16b263a243c6ce109f338e9;p=dealii.git Disable floating point exceptions for tests that specifically test is_nan. This is necessary because, very helpfully, the isnan() function throws a floating point exception when encountering NaN if floating point exceptions are enabled. --- diff --git a/tests/base/is_finite.cc b/tests/base/is_finite.cc index f801526806..bc71920e8d 100644 --- a/tests/base/is_finite.cc +++ b/tests/base/is_finite.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2005 - 2014 by the deal.II authors +// Copyright (C) 2005 - 2015 by the deal.II authors // // This file is part of the deal.II library. // @@ -21,6 +21,7 @@ #include #include #include +#include template @@ -62,6 +63,17 @@ int main () deallog.depth_console(0); deallog.threshold_double(1.e-10); + // the isnan() function (which we call in is_finite()) helpfully + // produces a floating point exception when called with a signalling + // NaN if FP exceptions are on. this of course makes it completely + // unusable since we can no longer detect whether something is a + // NaN. that said, to make the test work in these cases, simply + // switch off floating point exceptions for invalid arguments +#if defined(DEAL_II_HAVE_FP_EXCEPTIONS) + fedisableexcept(FE_INVALID); +#endif + + check (); check (); diff --git a/tests/base/is_finite_complex.cc b/tests/base/is_finite_complex.cc index 7177f8430f..e0d2a99981 100644 --- a/tests/base/is_finite_complex.cc +++ b/tests/base/is_finite_complex.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2005 - 2014 by the deal.II authors +// Copyright (C) 2005 - 2015 by the deal.II authors // // This file is part of the deal.II library. // @@ -21,6 +21,7 @@ #include #include #include +#include template @@ -70,6 +71,16 @@ int main () deallog.depth_console(0); deallog.threshold_double(1.e-10); + // the isnan() function (which we call in is_finite()) helpfully + // produces a floating point exception when called with a signalling + // NaN if FP exceptions are on. this of course makes it completely + // unusable since we can no longer detect whether something is a + // NaN. that said, to make the test work in these cases, simply + // switch off floating point exceptions for invalid arguments +#if defined(DEAL_II_HAVE_FP_EXCEPTIONS) + fedisableexcept(FE_INVALID); +#endif + check > (); check > (); diff --git a/tests/base/log_nan.cc b/tests/base/log_nan.cc index 8c890405d9..cc43164a4e 100644 --- a/tests/base/log_nan.cc +++ b/tests/base/log_nan.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2005 - 2014 by the deal.II authors +// Copyright (C) 2005 - 2015 by the deal.II authors // // This file is part of the deal.II library. // @@ -22,6 +22,7 @@ #include #include #include +#include int main () { @@ -31,6 +32,16 @@ int main () deallog.depth_console(0); deallog.threshold_double(1.e-10); + // the isnan() function (which we call in is_finite()) helpfully + // produces a floating point exception when called with a signalling + // NaN if FP exceptions are on. this of course makes it completely + // unusable since we can no longer detect whether something is a + // NaN. that said, to make the test work in these cases, simply + // switch off floating point exceptions for invalid arguments +#if defined(DEAL_II_HAVE_FP_EXCEPTIONS) + fedisableexcept(FE_INVALID); +#endif + deallog << std::numeric_limits::quiet_NaN() << std::endl; deallog << std::numeric_limits::signaling_NaN() << std::endl;