Re: [PATCH 1/2] Avoid implicit floating point conversions [v2]

Corinna Vinschen via Newlib <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Aug 20 17:35, Keith Packard via Newlib wrote:
> These were found with clang -Wdouble-promotion and show places where
> floating point values were being implicitly converted between
> representations. These conversions can result in unexpected use of
> double precision arithmetic. Those which are intentional all have an
> explicit cast added.
> [...]
> diff --git a/newlib/libm/common/exp.c b/newlib/libm/common/exp.c
> index 12c08c992..f3e95c6f5 100644
> --- a/newlib/libm/common/exp.c
> +++ b/newlib/libm/common/exp.c
> @@ -114,9 +114,9 @@ exp (double x)
>  	return WANT_ROUNDING ? 1.0 + x : 1.0;
>        if (abstop >= top12 (1024.0))
>  	{
> -	  if (asuint64 (x) == asuint64 (-INFINITY))
> +	  if (asuint64 (x) == asuint64 ((double) -INFINITY))
>  	    return 0.0;
> -	  if (abstop >= top12 (INFINITY))
> +	  if (abstop >= top12 ((double) INFINITY))

Not taking implicit compiler optimisations into account, wouldn't it
make more sense to avoid the conversion altogether, using
__builtin_inf() in these places?


Thanks,
Corinna
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.