public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* isnan and exceptions
@ 2020-08-28 15:23 Florian Weimer
  2020-09-01 20:31 ` Adhemerval Zanella
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2020-08-28 15:23 UTC (permalink / raw)
  To: libc-help

It seems that __builtin_isnanl raises Invalid Operation for sNaNs on
x86-64, but glibc's isnanl implementation does not.

Is this expected?  Are both behaviors correct?

The background of my question is that if I replace isnanl with this:

int
isnanl (long double x)
{
  return __builtin_isnanl (x);
}

I get these test suite failures:

testing long double (without inline functions)
Failure: isnan (sNaN): Exception "Invalid operation" set
Failure: isnan (-sNaN): Exception "Invalid operation" set
Failure: isnan_downward (sNaN): Exception "Invalid operation" set
Failure: isnan_downward (-sNaN): Exception "Invalid operation" set
Failure: isnan_towardzero (sNaN): Exception "Invalid operation" set
Failure: isnan_towardzero (-sNaN): Exception "Invalid operation" set
Failure: isnan_upward (sNaN): Exception "Invalid operation" set
Failure: isnan_upward (-sNaN): Exception "Invalid operation" set

Thanks,
Florian


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: isnan and exceptions
  2020-08-28 15:23 isnan and exceptions Florian Weimer
@ 2020-09-01 20:31 ` Adhemerval Zanella
  0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella @ 2020-09-01 20:31 UTC (permalink / raw)
  To: Florian Weimer, libc-help



On 28/08/2020 12:23, Florian Weimer via Libc-help wrote:
> It seems that __builtin_isnanl raises Invalid Operation for sNaNs on
> x86-64, but glibc's isnanl implementation does not.
> 
> Is this expected?  Are both behaviors correct?
> 
> The background of my question is that if I replace isnanl with this:
> 
> int
> isnanl (long double x)
> {
>   return __builtin_isnanl (x);
> }
> 
> I get these test suite failures:
> 
> testing long double (without inline functions)
> Failure: isnan (sNaN): Exception "Invalid operation" set
> Failure: isnan (-sNaN): Exception "Invalid operation" set
> Failure: isnan_downward (sNaN): Exception "Invalid operation" set
> Failure: isnan_downward (-sNaN): Exception "Invalid operation" set
> Failure: isnan_towardzero (sNaN): Exception "Invalid operation" set
> Failure: isnan_towardzero (-sNaN): Exception "Invalid operation" set
> Failure: isnan_upward (sNaN): Exception "Invalid operation" set
> Failure: isnan_upward (-sNaN): Exception "Invalid operation" set

I think it is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66462 

As Wilco has noted, using unordered floating point comparison in
isnan expansion is not fully correct and as patch has been submitted
but later revert on gcc.  The last iteration [1] seems handle the
raised issues, but it was never committed. 

[1] https://gcc.gnu.org/legacy-ml/gcc-patches/2016-11/msg02567.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-01 20:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 15:23 isnan and exceptions Florian Weimer
2020-09-01 20:31 ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).