From 200c967dfa7217c4dd8fc5b1bfad36571a6ed9b7 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/17] 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 028c22e6fb..912145c5b5 100644
--- a/src/main/eval.c
+++ b/src/main/eval.c
@@ -4436,9 +4436,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
-- 
2.18.0

