[PATCH] Remove __isinf uses that rely on signed return value
Joseph Myers
joseph@codesourcery.com
Tue Jun 2 20:35:00 GMT 2015
On Tue, 2 Jun 2015, Szabolcs Nagy wrote:
> On 02/06/15 18:15, Wilco Dijkstra wrote:
> > The printf code contains a few uses of __isinf where the sign is used - replace these with separate
> > isinf and signbit. Also change __isnan into isnan.
>
> i suspect it slightly changes semantics on x86 (for the better).
It shouldn't. isnan, the type-generic macro, just calls __isnanf /
__isnan / __isnanl depending on the type of the argument.
> i386 __isnanl does not seem to handle invalid ld80 representations.
>
> if exponent != 0 and significand>>63 == 0 then it's a "pseudo normal"
> or "pseudo infinite" value that the fpu would categorize as nan, but
> not __isnanl.
>
> (passing around long doubles with invalid representation is ub,
> but probably __isnanl should be consistent with fcom instruction
> to be safe when it is used on random bytes).
glibc policy on invalid long double values (both ldbl-96 and I think
ldbl-128ibm) is bounded undefined behavior (unspecified result,
unspecified exceptions, no expectation of any consistency, but should
avoid crashing the program / out-of-bounds stores).
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list