From ripley at stats.ox.ac.uk  Tue Jan  4 23:15:48 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue Jan  4 23:16:00 2005
Subject: [Rd] Re: [R] ISNAN() broken? in ver 2.x on MacOS X
In-Reply-To: <8E8CBC38-5E9C-11D9-97FA-000393D3D676@unsw.edu.au>
References: <A4F69DCB-5DF4-11D9-97FA-000393D3D676@unsw.edu.au>
	<Pine.A41.4.61b.0501031842590.322794@homer06.u.washington.edu>
	<4B294EEC-5E1C-11D9-97FA-000393D3D676@unsw.edu.au>
	<Pine.LNX.4.61.0501040801141.1630@gannet.stats>
	<B16B6AC2-5E45-11D9-97FA-000393D3D676@unsw.edu.au>
	<Pine.LNX.4.61.0501041210010.30424@gannet.stats>
	<x2vfadz79n.fsf@biostat.ku.dk>
	<8E8CBC38-5E9C-11D9-97FA-000393D3D676@unsw.edu.au>
Message-ID: <Pine.LNX.4.61.0501042205560.6578@gannet.stats>

On Wed, 5 Jan 2005, Bill Northcott wrote:

> On 04/01/2005, at 11:52 PM, Peter Dalgaard wrote:
>> Prof Brian Ripley <ripley@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@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


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