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

Corinna Vinschen vinschen@redhat.com
Tue Aug 25 11:10:09 GMT 2020


On Aug 24 08:33, Keith Packard via Newlib wrote:
> Corinna Vinschen via Newlib <newlib@sourceware.org> writes:
> 
> > Not taking implicit compiler optimisations into account, wouldn't it
> > make more sense to avoid the conversion altogether, using
> > __builtin_inf() in these places?
> 
> Yeah, could do that instead. I think it's mostly a matter of what looks
> better -- using the "standard" value of INFINITY and casting or using a
> compiler internal value without. I think it'll confuse an equal number
> of people either way.
> 
> Any preferences?

__builtin_inf(), or a sufficiently expressive macro.  It's pretty
unfortunate that POSIX defines INFINITY and NAN as float, rather than
providing type-matching macros as in HUGE_VALF - HUGE_VAL - HUGE_VALL.

Something like #define _INF (__builtin_inf()) comes to mind.


Corinna



More information about the Newlib mailing list