#1121: gcc 4.6+ compiler bug for isnan ----------------------+----------------------------------------------------- Reporter: sbrandt | Owner: eschnett Type: defect | Status: assigned Priority: minor | Milestone: ET_2012_11 Component: Carpet | Version: development version Resolution: | Keywords: ----------------------+-----------------------------------------------------
Comment (by eschnett):
I attach a patch that solves this problem by using autoconf to decided how to call isnan etc.
In addition to providing a macro CCTK_ISNAN, there is also a C function CCTK_isnan defined that can be called from C++, providing a fallback if necessary.
If C++ does not provide a proper implementation of isnan, i.e. one that can be called as std::isnan, then define a macro isnan to correct this. That is, one can now always call std::isnan to get a good definition of isnan.
Add a test thorn TestMath.
Remove the respective magic from Carpet.
Update various locations that use isnan.
Update thorn NaNChecker: - use std::isnan - simplify check_for logic - don't call C++ isnan, which is known to be optimised away in certain cases; instead, call the C isnan (via CCTK_isnan) that is not optimised away