From luke-tierney at uiowa.edu  Mon Sep 14 23:40:16 2015
From: luke-tierney at uiowa.edu (luke-tierney at uiowa.edu)
Date: Mon, 14 Sep 2015 16:40:16 -0500
Subject: [Rd] Optimization bug when byte compiling with gcc 5.2.0 on
 windows
In-Reply-To: <CABFfbXtcL-Lv=yJwSQeoZs5BxHsSfLen8tE1j2dDe2zSHYYzQw@mail.gmail.com>
References: <CABFfbXsdT2-jBdaqr4oCtZ2AvBWZ++tQHa49DyWc=m3G_qE7bw@mail.gmail.com>
	<alpine.LFD.2.20.1509140826370.19382@itasca.stat.uiowa.edu>
	<55F6D6A7.3060603@gmail.com>
	<CABFfbXtsZwUhQGdVG-3OAq_bReZGNkSJ2SRVpXkrFT06a7AuYg@mail.gmail.com>
	<CABFfbXtcL-Lv=yJwSQeoZs5BxHsSfLen8tE1j2dDe2zSHYYzQw@mail.gmail.com>
Message-ID: <alpine.DEB.2.10.1509141637220.2561@luke-Latitude>

On Mon, 14 Sep 2015, Jeroen Ooms wrote:

> On Mon, Sep 14, 2015 at 8:49 PM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu> wrote:
>
>> I tested this hypothesis by replacing '__GNUC__ <= 4' with '__GNUC__
>> <= 5' and rebuilding R, but this introduces a whole lot of problems
>> that were not there before. In particular R crashes when using the
>> graphics device, which it did not without this fix.
>
> I found that the problem goes away when we use isnanl() instead of
> isnan(). This is very similar to the problem we have for R_pow() where
> we need to use powl() instead of pow() for recent versions mingw-w64
> (this still needs to be patched in r-devel).
>
> So the full solution is:
>
> #if (defined(_WIN32) || defined(_WIN64)) && defined(__GNUC__)
> # define R_sqrt(x) (isnanl(x) ? x : sqrt(x))
> #else
> # define R_sqrt sqrt
> #endif

That can't possibly be the right solution. We use ISNAN in lots of
places and long doubles in very few.

Best,

luke

>
> Below the relevant mingw-w64 sources:
>
> https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-crt/math/isnan.c
> https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-crt/math/isnanf.c
> https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-crt/math/isnanl.c
>
> I think mingw-w64 takes powl from glibc.
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] Optimization bug when byte compiling with gcc 5.2.0 on windows
luke-tierney at uiowa.edu