This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Remove __isinf uses that rely on signed return value
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- Cc: Wilco Dijkstra <wdijkstr at arm dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 2 Jun 2015 20:20:30 +0000
- Subject: Re: [PATCH] Remove __isinf uses that rely on signed return value
- Authentication-results: sourceware.org; auth=none
- References: <001301d09d57$c0bfdf60$423f9e20$ at com> <556DEF45 dot 4030808 at arm dot com>
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