On Sat, 28 Feb 2026 at 04:19, LIU Hao <[email protected]> wrote: > 在 2026-2-28 03:16, Erez Geva via Mingw-w64-public 写道: > > From: Erez Geva <[email protected]> > > > > Signed-off-by: Erez Geva <[email protected]> > > Signed-off-by: Erez Geva <[email protected]> > > --- > > mingw-w64-headers/crt/math.h | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/mingw-w64-headers/crt/math.h b/mingw-w64-headers/crt/math.h > > index 03cedde34..db66bbca5 100644 > > --- a/mingw-w64-headers/crt/math.h > > +++ b/mingw-w64-headers/crt/math.h > > @@ -495,13 +495,13 @@ __fin))) > > #define fpclassify(x) \ > > __mingw_choose_expr ( \ > > __mingw_types_compatible_p (__typeof__ (x), double), \ > > - __fpclassify(x), \ > > + __fpclassify((double)x), \ > > This shall be `(double)(x)`. >
Of course, Sorry for missing it, and the two other casting. > > But, would you please show a piece of code about the necessity of these > casts? The C standard (7.12.3 > Classification macros, n3220) requires that the argument to one of the > classification macros 'shall' be a > floating-point type; otherwise it's a constraint violation and results in > undefined behavior. > > We cast float or double or long float to float or double or long double. When you performa implicit downcasting, i.e. double to float or long double to double or float, the compiler warns you as you may lose information stored in the higher capacity type. Notice we are only talking about floating point types, we comply with the standard! From https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html: Wfloat-conversion <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wfloat-conversion> Warn for *implicit conversions* that reduce the precision of a real value. This includes conversions from real to integer, and from *higher precision real to lower precision real values*. This option is also enabled by -Wconversion. That is why the macro "isnan(x)" which uses the same structure is using explicit casting. See: https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-headers/crt/math.h#l589 The casting "__isnanl((long double)(x))" is not really needed, as x must be a float type and can only be upcasted or already using long double. But I guess it was added for symmetric, prettiness and for possible future higher floating point types. Erez > > > -- > Best regards, > LIU Hao > _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
