[Rd] Re: [R] ISNAN() broken? in ver 2.x on MacOS X

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jan 4 23:15:48 CET 2005


On Wed, 5 Jan 2005, Bill Northcott wrote:

> On 04/01/2005, at 11:52 PM, Peter Dalgaard wrote:
>> Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
>> 
>>> R has no such bug number, nor does any search I do come up with
>>> anything similar.
>> 
>> The Cc: line suggests that it is a gcc PR#. Guess who fell into the
>> same trap...
>> 
> That is indeed a gcc bugzilla problem report number.

How about apologizing for such a badly written message?

> It seems the gcc maintainers are agreed that it is too hard to fix at 
> this time.  The workarounds suggested in the PR 14608 don't work on 
> MacOS X, and probably don't work on other platforms because the undefs 
> of the math.h macros in cmath are not conditional.
>
> So what might be the 'take away' for R?  Possibilities:
>
> 1.  Amend the documentation:  add a note to 'Missing and IEEE special values' 
> in 'Writing R extensions' to the effect that the macros should not be used 
> with C++.  Currently they will break on several platforms.

Why?  This is a g++ problem, not a C++ problem, and at least one C++ 
compiler works.  Have you tried Thomas's suggestion to use isnan?

> 2. The work-around that strikes me is to use R_IsNaN instead, which was the 
> approach used in R v1.9 for non-IEEE platforms and when used standalone. 
> Unfortunately this API was changed between v1.9 and v2.0.  That is no problem

No change was made to the API in 2.0.x.  The API specified ISNAN then and 
now.  Please do us the courtesy of checking your facts.

> when building against an installed R as there is a macro for the Version. 
> However, if building standalone, I can see no way to get the version short of 
> an autoconf macro to test for the symbols in the library.
>
> 3. Perhaps the macro substitution of R_IsNaN for ISNAN etc. could be 
> reintroduced into v2.0.x conditional on C++.  That might need a new ISNA() 
> macro.

You cannot `reintroduce' something you never had.  We had in 1.9.x

#ifdef IEEE_754
# define ISNAN(x) (isnan(x)!=0)
#else
# define ISNAN(x)      R_IsNaNorNA(x)
#endif

Please do your homework!

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list