Test case:

  #include <math.h>
  int isnan_wrapper(double value) { return isnan(value); }

Output:

  $ g++ -Wconversion -c snippet.cpp
  warning: conversion to 'float' from 'double' may alter its value
  warning: conversion to 'int' from 'double' may alter its value

First warning is caused by the fact in C++ mode is __mingw_choose_expr
using ternary operator and warning is triggered also case which is not
called.

Second warning is caused by the fact that type of expression
(__builtin_trap(),x) for isnan(x) is double, but return value of
isnan_wrapper() is int. But this expression never returns.

Fix the first problem to use explicit cast for __isnan* calls which
correspondents to matched __mingw_types_compatible_p types.

And fix second problem by changing expression to something which has type
of int.

Bug: https://sourceforge.net/p/mingw-w64/bugs/481/
---
 mingw-w64-headers/crt/math.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-headers/crt/math.h b/mingw-w64-headers/crt/math.h
index cacdd4753366..5cc24a20609e 100644
--- a/mingw-w64-headers/crt/math.h
+++ b/mingw-w64-headers/crt/math.h
@@ -594,14 +594,14 @@ __mingw_choose_expr (                                     
    \
 #define isnan(x) \
 __mingw_choose_expr (                                         \
   __mingw_types_compatible_p (__typeof__ (x), double),            \
-    __isnan(x),                                                 \
+    __isnan((double)(x)),                                         \
     __mingw_choose_expr (                                     \
       __mingw_types_compatible_p (__typeof__ (x), float),         \
-        __isnanf(x),                                            \
+        __isnanf((float)(x)),                                     \
     __mingw_choose_expr (                                     \
       __mingw_types_compatible_p (__typeof__ (x), long double),   \
-        __isnanl(x),                                            \
-    __dfp_expansion(__isnan,(__builtin_trap(),x),x))))
+        __isnanl((long double)(x)),                               \
+    __dfp_expansion(__isnan,(__builtin_trap(),(int)0),x))))
 
 /* 7.12.3.5 */
 #define isnormal(x) (fpclassify(x) == FP_NORMAL)
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to