On Tue, 24 Nov 2020, Siddhesh Poyarekar wrote:

> The third alternative (which seems like a step back to me, but will concede
> that it is a valid resolution) is to state that unnormal input to isnanl would
> result in undefined behaviour and hence it is the responsibility of the
> application to ensure that inputs to isnanl are never unnormal.

glibc effectively treats them as unspecified behavior - we don't expect 
them to produce any particular meaningful function return value (this 
includes the possibility that such an invalid encoding might be returned 
by a function given such an encoding as input), but if they result in 
buffer overflows, infinite loops or similar, that's fixed as a bug.

Note that there are lots of libm function implementations, not just 
isnanl, which work by looking at the encoding without considering the 
possibility it might be one of the kinds of encodings (other than sNaN) 
that cannot result from floating-point arithmetic.  This includes both 
ldbl-96 implementations in C and implementations in assembly for i386 and 
x86_64, and probably implementations for m68k and ia64 as well.  
iscanonical is the only operation in glibc that deliberately tries to 
detect and produce defined results for these encodings.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to