From patchwork Thu Jun 22 22:47:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 21217 Received: (qmail 85140 invoked by alias); 22 Jun 2017 22:47:20 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 84546 invoked by uid 89); 22 Jun 2017 22:47:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Thu, 22 Jun 2017 22:47:03 +0000 From: Joseph Myers To: Subject: Correct min_of_type handling of _Float128 [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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). Committed. 2017-06-22 Joseph Myers * 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. diff --git a/sysdeps/generic/math_private.h b/sysdeps/generic/math_private.h index 6ea5e25..1418bbd 100644 --- a/sysdeps/generic/math_private.h +++ b/sysdeps/generic/math_private.h @@ -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. */