From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 6F9281F55B for ; Sat, 23 May 2020 19:18:36 +0000 (UTC) Received: from localhost ([::1]:49756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcZfH-0002dW-AM for normalperson@yhbt.net; Sat, 23 May 2020 15:18:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcZfA-0002dO-1o for bug-gnulib@gnu.org; Sat, 23 May 2020 15:18:28 -0400 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:30256) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcZf7-0000sv-Ri for bug-gnulib@gnu.org; Sat, 23 May 2020 15:18:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1590261503; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=ASrx+YpWLGOKM602CN0cexpCjNKHcz0VuDLG9AI126Q=; b=fCZWOcxS2f6DpV+m/zB8Yo9C5Ayd3QQ81jlrlRn0D9kRsZygGTlGHsgqfnmLtsXwEX inhs4wT64XQvbLDjDOVnDcgD5quUk7ydhr9VDAv/QNjsjZGD1mNKsxIooL+8P6upBKLt 4+Nq7So8gxjCU40tGmprfXXuEcMcoxhOKb2uRjm2UoljiUFQLQ/493n3Wfp8+bzD27Sm BXi2gLNqyBwFpM1J4j6xpebQbdE+UYBOo4K2r5wRh3p3d4X15IgIwZ4JFKfJ0aPnh9aR PF87APddXh3yLxH4i3G9/LgvZw2/iDBQo7hKoz95k4xET4EwdHmAyJWx0kx/pa2bfP2K 7/+Q== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.7.0 DYNA|AUTH) with ESMTPSA id x0bd30w4NJIMQ74 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sat, 23 May 2020 21:18:22 +0200 (CEST) From: Bruno Haible To: Tim =?ISO-8859-1?Q?R=FChsen?= Subject: Fix invalid use of __builtin_isnanf and __builtin_isnanl Date: Sat, 23 May 2020 21:18:21 +0200 Message-ID: <5583426.vCNMNYEF0V@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <10131976.Az27LhXeeQ@omega> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Received-SPF: none client-ip=2a01:238:20a:202:5300::5; envelope-from=bruno@clisp.org; helo=mo6-p00-ob.smtp.rzone.de X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Tim R=FChsen wrote: > - gcc-10 with unset CFLAGS (*.gcc-10) > - clang-10 with unset CFLAGS (*.clang-10) Another difference between these test results is this: =2Dgl_cv_func_isnanf_no_libm=3D${gl_cv_func_isnanf_no_libm=3Dyes} =2Dgl_cv_func_isnanf_works=3D${gl_cv_func_isnanf_works=3Dyes} =2Dgl_cv_func_isnanl_no_libm=3D${gl_cv_func_isnanl_no_libm=3Dyes} =2Dgl_cv_func_isnanl_works=3D${gl_cv_func_isnanl_works=3Dyes} +gl_cv_func_isnanf_in_libm=3D${gl_cv_func_isnanf_in_libm=3Dno} +gl_cv_func_isnanf_no_libm=3D${gl_cv_func_isnanf_no_libm=3Dno} +gl_cv_func_isnanl_in_libm=3D${gl_cv_func_isnanl_in_libm=3Dno} +gl_cv_func_isnanl_no_libm=3D${gl_cv_func_isnanl_no_libm=3Dno} config.log shows that clang has no __builtin_isnanf and __builtin_isnanl, although it defines __GNUC__ to a value >=3D 4. This patch fixes it. 2020-05-23 Bruno Haible isnanf, isnanl, isnan: Don't use nonexistent builtins with clang. * m4/isnanf.m4 (gl_HAVE_ISNANF_NO_LIBM, gl_HAVE_ISNANF_IN_LIBM, gl_ISNANF_WORKS): Don't use __builtin_isnanf on clang versions that don't have it. * m4/isnanl.m4 (gl_HAVE_ISNANL_NO_LIBM, gl_HAVE_ISNANL_IN_LIBM, gl_FUNC_ISNANL_WORKS): Don't use __builtin_isnanl on clang versions that don't have it. * lib/isnanf-nolibm.h (__has_builtin): New macro. (isnanf): Don't use __builtin_isnanf on clang versions that don't have it. * lib/isnanl-nolibm.h (__has_builtin): New macro. (isnanl): Don't use __builtin_isnanl on clang versions that don't have it. * lib/math.in.h (__has_builtin): New macro. (isnanf): Don't use __builtin_isnanf on clang versions that don't have it. (isnanl): Don't use __builtin_isnanl on clang versions that don't have it. (isnan): Don't use the builtins on clang versions that don't have __builtin_isnanf and __builtin_isnanl. diff --git a/lib/isnanf-nolibm.h b/lib/isnanf-nolibm.h index 647ffed..17a2f5e 100644 =2D-- a/lib/isnanf-nolibm.h +++ b/lib/isnanf-nolibm.h @@ -17,7 +17,10 @@ #if HAVE_ISNANF_IN_LIBC /* Get declaration of isnan macro or (older) isnanf function. */ # include =2D# if __GNUC__ >=3D 4 +# ifndef __has_builtin +# define __has_builtin(name) 0 +# endif +# if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (__builtin_is= nanf)) /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) diff --git a/lib/isnanl-nolibm.h b/lib/isnanl-nolibm.h index c45e3ab..103d31a 100644 =2D-- a/lib/isnanl-nolibm.h +++ b/lib/isnanl-nolibm.h @@ -17,7 +17,10 @@ #if HAVE_ISNANL_IN_LIBC /* Get declaration of isnan macro or (older) isnanl function. */ # include =2D# if __GNUC__ >=3D 4 +# ifndef __has_builtin +# define __has_builtin(name) 0 +# endif +# if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (__builtin_is= nanl)) /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) diff --git a/lib/math.in.h b/lib/math.in.h index e5e37d6..30465f8 100644 =2D-- a/lib/math.in.h +++ b/lib/math.in.h @@ -127,6 +127,12 @@ static void (*_gl_math_fix_itold) (long double *, int)= =3D _Qp_itoq; #endif =20 =20 +/* For clang: Use __has_builtin to determine whether a builtin is availabl= e. */ +#ifndef __has_builtin +# define __has_builtin(name) 0 +#endif + + /* POSIX allows platforms that don't support NAN. But all major machines in the past 15 years have supported something close to IEEE NaN, so we define this unconditionally. We also must define @@ -2318,7 +2324,7 @@ _GL_WARN_REAL_FLOATING_DECL (isinf); # if @HAVE_ISNANF@ /* The original included above provides a declaration of isnan ma= cro or (older) isnanf function. */ =2D# if __GNUC__ >=3D 4 +# if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (__builtin_i= snanf)) /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) @@ -2362,7 +2368,7 @@ _GL_EXTERN_C int isnand (double x); # if @HAVE_ISNANL@ /* The original included above provides a declaration of isnan macro or (older) isnanl function. */ =2D# if __GNUC__ >=3D 4 +# if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (__builtin_i= snanl)) /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) @@ -2385,7 +2391,7 @@ _GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE= _CONST; isnanf.h (e.g.) here, because those may end up being macros that recursively expand back to isnan. So use the gnulib replacements for them directly. */ =2D# if @HAVE_ISNANF@ && __GNUC__ >=3D 4 +# if @HAVE_ISNANF@ && __GNUC__ >=3D 4 && (!defined __clang__ || __has_bui= ltin (__builtin_isnanf)) # define gl_isnan_f(x) __builtin_isnanf ((float)(x)) # else _GL_EXTERN_C int rpl_isnanf (float x); @@ -2397,7 +2403,7 @@ _GL_EXTERN_C int rpl_isnanf (float x); _GL_EXTERN_C int rpl_isnand (double x); # define gl_isnan_d(x) rpl_isnand (x) # endif =2D# if @HAVE_ISNANL@ && __GNUC__ >=3D 4 +# if @HAVE_ISNANL@ && __GNUC__ >=3D 4 && (!defined __clang__ || __has_bui= ltin (__builtin_isnanl)) # define gl_isnan_l(x) __builtin_isnanl ((long double)(x)) # else _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; @@ -2408,7 +2414,7 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRI= BUTE_CONST; (sizeof (x) =3D=3D sizeof (long double) ? gl_isnan_l (x) : \ sizeof (x) =3D=3D sizeof (double) ? gl_isnan_d (x) : \ gl_isnan_f (x)) =2D# elif __GNUC__ >=3D 4 +# elif __GNUC__ >=3D 4 && (!defined __clang__ || (__has_builtin (__builtin= _isnanf) && __has_builtin (__builtin_isnanl))) # undef isnan # define isnan(x) \ (sizeof (x) =3D=3D sizeof (long double) ? __builtin_isnanl ((long doubl= e)(x)) : \ diff --git a/m4/isnanf.m4 b/m4/isnanf.m4 index 4e9fb48..7dd67bd 100644 =2D-- a/m4/isnanf.m4 +++ b/m4/isnanf.m4 @@ -1,4 +1,4 @@ =2D# isnanf.m4 serial 15 +# isnanf.m4 serial 16 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -74,7 +74,10 @@ AC_DEFUN([gl_HAVE_ISNANF_NO_LIBM], AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include =2D #if __GNUC__ >=3D 4 + #ifndef __has_builtin + # define __has_builtin(name) 0 + #endif + #if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (= __builtin_isnanf)) # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) #elif defined isnan @@ -99,7 +102,10 @@ AC_DEFUN([gl_HAVE_ISNANF_IN_LIBM], AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include =2D #if __GNUC__ >=3D 4 + #ifndef __has_builtin + # define __has_builtin(name) 0 + #endif + #if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (= __builtin_isnanf)) # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) #elif defined isnan @@ -127,7 +133,10 @@ AC_DEFUN([gl_ISNANF_WORKS], AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include =2D#if __GNUC__ >=3D 4 +#ifndef __has_builtin +# define __has_builtin(name) 0 +#endif +#if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (__builtin_isn= anf)) # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) #elif defined isnan diff --git a/m4/isnanl.m4 b/m4/isnanl.m4 index 9874418..75d54629 100644 =2D-- a/m4/isnanl.m4 +++ b/m4/isnanl.m4 @@ -1,4 +1,4 @@ =2D# isnanl.m4 serial 20 +# isnanl.m4 serial 21 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -68,7 +68,10 @@ AC_DEFUN([gl_HAVE_ISNANL_NO_LIBM], AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include =2D #if __GNUC__ >=3D 4 + #ifndef __has_builtin + # define __has_builtin(name) 0 + #endif + #if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (= __builtin_isnanl)) # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) #elif defined isnan @@ -93,7 +96,10 @@ AC_DEFUN([gl_HAVE_ISNANL_IN_LIBM], AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include =2D #if __GNUC__ >=3D 4 + #ifndef __has_builtin + # define __has_builtin(name) 0 + #endif + #if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (= __builtin_isnanl)) # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) #elif defined isnan @@ -123,7 +129,10 @@ AC_DEFUN([gl_FUNC_ISNANL_WORKS], #include #include #include =2D#if __GNUC__ >=3D 4 +#ifndef __has_builtin +# define __has_builtin(name) 0 +#endif +#if __GNUC__ >=3D 4 && (!defined __clang__ || __has_builtin (__builtin_isn= anl)) # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) #elif defined isnan