Re: [PATCH 3/6] Avoid implicit floating point conversions

Joseph Myers <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Thu, 20 Aug 2020, Keith Packard via Newlib wrote:

> diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h
> index 0a3ea97ed..13b300021 100644
> --- a/newlib/libc/include/complex.h
> +++ b/newlib/libc/include/complex.h
> @@ -9,8 +9,10 @@
>  #define	_COMPLEX_H
>  
>  #define complex _Complex
> -#define _Complex_I 1.0fi
> +#define _Complex_I 1.0i
> +#define _Complex_If 1.0if
>  #define I _Complex_I
> +#define I_f _Complex_If

This is contrary to the standard requirement that _Complex_I and I have 
type const float _Complex.

>  # ifndef INFINITY
> -#  define INFINITY (__builtin_inff())
> +#  define INFINITY (__builtin_inf())
> +# endif

This is contrary to the standard requirement that INFINITY has type float.

>  # ifndef NAN
> -#  define NAN (__builtin_nanf(""))
> +#  define NAN (__builtin_nan(""))
> +# endif

This is contrary to the standard requirement that NAN has type float.

>  #ifndef NO_ERRNO
> -  if (isinf (retval) && !isinf (val))
> +  if (isinff (retval) && !isinff (val))

isinf, isnan, etc. are *type-generic* macros.  If newlib is declaring them 
in a non-type-generic way, that should be fixed, rather than changing 
users to use a type-specific function.

-- 
Joseph S. Myers
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.