From cffd693401c16f084ea3b9988b9a438abd2e052e Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Tue, 2 Jan 2018 15:42:00 +0000
Subject: [PATCH 04/14] Win32: Extend sqrt NA_real_ hack to all GCC versions

Also fix for GCC 5.3 ISNAN(int) emitting UD2 insn
---
 src/main/eval.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/main/eval.c b/src/main/eval.c
index 4d6805dbf9..43651272e6 100644
--- a/src/main/eval.c
+++ b/src/main/eval.c
@@ -4889,9 +4889,8 @@ static SEXP cmp_arith2(SEXP call, int opval, SEXP opsym, SEXP x, SEXP y,
    called with NA_real_. Not sure this is a bug in the Windows
    toolchain or in our expectations, but these defines attempt to work
    around this. */
-#if (defined(_WIN32) || defined(_WIN64)) && defined(__GNUC__) && \
-    __GNUC__ <= 4
-# define R_sqrt(x) (ISNAN(x) ? x : sqrt(x))
+#if (defined(_WIN32) || defined(_WIN64)) && defined(__GNUC__)
+# define R_sqrt(x) (ISNAN((double)x) ? x : sqrt(x))
 #else
 # define R_sqrt sqrt
 #endif
