Re: [Rd] Optimization bug when byte compiling with gcc 5.2.0 on windows

2015-09-14 Thread luke-tierney
On Mon, 14 Sep 2015, Jeroen Ooms wrote: On Mon, Sep 14, 2015 at 8:49 PM, Jeroen Ooms 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 t

Re: [Rd] Optimization bug when byte compiling with gcc 5.2.0 on windows

2015-09-14 Thread Jeroen Ooms
On Mon, Sep 14, 2015 at 8:49 PM, Jeroen Ooms 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

Re: [Rd] Optimization bug when byte compiling with gcc 5.2.0 on windows

2015-09-14 Thread Jeroen Ooms
On Mon, Sep 14, 2015 at 4:16 PM, Duncan Murdoch wrote: > I think the reason for the earlier restriction is the assumption that > eventually gcc will be fixed and this workaround won't be necessary, but > apparently 5.2.0 still has the same problem. I tested this hypothesis by replacing '__GNUC__

Re: [Rd] Optimization bug when byte compiling with gcc 5.2.0 on windows

2015-09-14 Thread Duncan Murdoch
On 14/09/2015 9:36 AM, luke-tier...@uiowa.edu wrote: I believe the issue is that on Windows the sqrt function when called with a NaN does not return the same NaN, as it does on other platforms. We have #if (defined(_WIN32) || defined(_WIN64)) && defined(__GNUC__) && \ __GNUC__ <= 4 # defin

Re: [Rd] Optimization bug when byte compiling with gcc 5.2.0 on windows

2015-09-14 Thread luke-tierney
I believe the issue is that on Windows the sqrt function when called with a NaN does not return the same NaN, as it does on other platforms. We have #if (defined(_WIN32) || defined(_WIN64)) && defined(__GNUC__) && \ __GNUC__ <= 4 # define R_sqrt(x) (ISNAN(x) ? x : sqrt(x)) #else # define R_sq

Re: [Rd] Optimization bug when byte compiling with gcc 5.2.0 on windows

2015-09-14 Thread Simon Urbanek
Jeroen, the difference is that level 3 is using the internal implementation of sqrt in the compiler instead of calling the sqrt function. The internal path goes to R_sqrt which is defined as # define R_sqrt(x) (ISNAN(x) ? x : sqrt(x)) so you could check if that is where the problem happens. It

[Rd] Optimization bug when byte compiling with gcc 5.2.0 on windows

2015-09-14 Thread Jeroen Ooms
When building R-devel with gcc 5.2.0 (mingw-w64 v4) on Windows, make check fails reg-tests-1b.R at the following check: x <- c(1:2, NA) sx <- sd(x) !is.nan(sx) Here 'sx' should be 'NA' but it is 'NaN'. It turns out this problem only appears when the function is byte compiled with optimizati