[PATCH 3/6] Avoid implicit floating point conversions

Joseph Myers joseph@codesourcery.com
Thu Aug 20 22:43:23 GMT 2020


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
joseph@codesourcery.com


More information about the Newlib mailing list