public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* ilogbl(NaN) is wrong
@ 2023-04-18 11:21 Bruno Haible
  2023-04-18 11:56 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Bruno Haible @ 2023-04-18 11:21 UTC (permalink / raw)
  To: cygwin

POSIX [1] specifies that the return value of the functions ilogbf(), ilogb(),
ilogbl() for a NaN argument should all be the same, namely FP_ILOGBNAN.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/ilogb.html

In Cygwin 3.4.6, the value of ilogbl(NaN) is not right.

How to reproduce:
============================== foo.c ==============================
#include <math.h>
#include <float.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int
main (void)
{
  volatile double x1;
  volatile long double x2;
  int y1;
  int y2;

  x1 = 0.0 / 0.0;
  y1 = ilogb (x1);

  x2 = 0.0L / 0.0L;
  y2 = ilogbl (x2);

  printf ("%d %d %d\n", y1, y2, FP_ILOGBNAN);

  if (!(y1 == FP_ILOGBNAN))
    abort ();

  /* This test fails in Cygwin 3.4.6.  */
  if (!(y2 == FP_ILOGBNAN))
    abort ();

  if (!(FP_ILOGBNAN == INT_MAX || FP_ILOGBNAN == INT_MIN))
    abort ();
}
===================================================================
$ gcc -Wall foo.c
$ ./a.exe

Expected output:
2147483647 2147483647 2147483647

Actual output:
2147483647 -2147483648 2147483647
Aborted (core dumped)

Bruno

PS: This is about the same function, but not the argument value, as in
https://cygwin.com/pipermail/cygwin/2019-December/243205.html




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

* Re: ilogbl(NaN) is wrong
  2023-04-18 11:21 ilogbl(NaN) is wrong Bruno Haible
@ 2023-04-18 11:56 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2023-04-18 11:56 UTC (permalink / raw)
  To: Bruno Haible; +Cc: cygwin

On Apr 18 13:21, Bruno Haible via Cygwin wrote:
> POSIX [1] specifies that the return value of the functions ilogbf(), ilogb(),
> ilogbl() for a NaN argument should all be the same, namely FP_ILOGBNAN.
> 
> [1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/ilogb.html
> 
> In Cygwin 3.4.6, the value of ilogbl(NaN) is not right.

Thanks, I pushed a patch.

A test release cygwin-3.5.0-0.283.gfa84aa4dd2fb containing this patch
is building right now.  You can install it via setup as soon as it's
available (roughly in an hour).


Thanks again,
Corinna


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

end of thread, other threads:[~2023-04-18 11:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 11:21 ilogbl(NaN) is wrong Bruno Haible
2023-04-18 11:56 ` Corinna Vinschen

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).