Skip to content
Prev 61732 / 398498 Next

ISNAN() broken? in ver 2.x on MacOS X

I see you are quite correct that IEEE_754 is defined in Rconfig.h on 
MacOS X.  However, I was building against a standalone libRmath v1.9.1. 
  So I was including Rmath.h only and IEEE_754 was not defined.  The 
result was that I got R_IsNaNorNA in the preprocessed source.

I finally found it.  The culprit is
#include <iostream>
which is used in our real code

If I preprocess the following code then the substitution is ISNAN() --> 
(isnan(x)!=0)
#include <iostream>
#include <R.h>
#include <Rmath.h>
ISNAN(x);

Removing the #include <iostream> the substitution becomes
ISNAN(x)   --> (( ( sizeof ( x ) == sizeof(double) ) ? __isnand ( x ) : 
( sizeof ( x ) == sizeof( float) ) ? __isnanf ( x ) : __isnan ( x ) 
)!=0)
which is correct.

This behaviour is the same with both gcc 3.3 and pre-release gcc 4.0 on 
MacOS X 10.3.7.

Is this a bug we should report to someone such the gcc maintainers?

Bill Northcott
On 04/01/2005, at 1:48 PM, Thomas Lumley wrote: