]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Correct min_of_type handling of _Float128.
authorJoseph Myers <joseph@codesourcery.com>
Thu, 22 Jun 2017 22:46:27 +0000 (22:46 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 22 Jun 2017 22:46:27 +0000 (22:46 +0000)
The math_private.h macro min_of_type has broken _Float128 handling:
instead of passing its type argument to the key __EXPR_FLT128 macro,
it passes x, which is not a macro argument but whatever variable
called x happens to be visible in the calling function.  If that
variable has the wrong type, the wrong one of long double and
_Float128 can get chosen.  In particular, this applies to some
_Complex long double functions (where x happens to have type _Complex
long double, resulting in min_of_type returning a _Float128 value when
it should return a long double value).  For some reason, this only
caused test failures for me on x86_64 with GCC 6 but not GCC 7 (I
suspect it triggers known bugs in conversions from x86 long double to
_Float128 that are present in GCC 6's soft-fp).

Tested for x86_64 (in conjunction with float128 patches).

* sysdeps/generic/math_private.h (__EXPR_FLT128): Do not apply
typeof to argument passed to __builtin_types_compatible_p.
(min_of_type): Pass type argument, not x, to __EXPR_FLT128.

ChangeLog
sysdeps/generic/math_private.h

index b9d30100d9ceaf719be2c981f19de3400a034426..cd886956ae761cd0be2ce79d40422bba8b4ce353 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-06-22  Joseph Myers  <joseph@codesourcery.com>
 
+       * sysdeps/generic/math_private.h (__EXPR_FLT128): Do not apply
+       typeof to argument passed to __builtin_types_compatible_p.
+       (min_of_type): Pass type argument, not x, to __EXPR_FLT128.
+
        * math/w_acos_template.c [__USE_WRAPPER_TEMPLATE]: Include
        <errno.h>.
        * math/w_acosh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
index 6ea5e25e5a3db48cf83e58fca63b5887c092495d..1418bbda27dcaa83c98d308689cd825ccb5075b2 100644 (file)
@@ -304,7 +304,7 @@ extern void __docos (double __x, double __dx, double __v[]);
 #if __HAVE_DISTINCT_FLOAT128
 # define __EXPR_FLT128(x, yes, no)                             \
   __builtin_choose_expr (__builtin_types_compatible_p          \
-                        (__typeof (x), long double), no, yes)
+                        (x, long double), no, yes)
 #else
 # define __EXPR_FLT128(x, yes, no) no
 #endif
@@ -318,7 +318,7 @@ extern void __docos (double __x, double __dx, double __v[]);
    __builtin_choose_expr                               \
    (__builtin_types_compatible_p (type, double),       \
     DBL_MIN,                                           \
-    __EXPR_FLT128 (x, FLT128_MIN, LDBL_MIN)))
+    __EXPR_FLT128 (type, FLT128_MIN, LDBL_MIN)))
 
 /* If X (which is not a NaN) is subnormal, force an underflow
    exception.  */