From w.northcott at unsw.edu.au  Tue Jan  4 23:04:08 2005
From: w.northcott at unsw.edu.au (Bill Northcott)
Date: Tue Jan  4 23:04:48 2005
Subject: [Rd] Re: [R] ISNAN() broken? in ver 2.x on MacOS X
In-Reply-To: <x2vfadz79n.fsf@biostat.ku.dk>
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>
Message-ID: <8E8CBC38-5E9C-11D9-97FA-000393D3D676@unsw.edu.au>

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.  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.

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 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.

Bill Northcott


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