Bug 43347 - log2(-1) does not set errno
log2(-1) does not set errno
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: libc (Show other bugs)
7.1
All Linux
low Severity low
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-06-03 11:24 EDT by Trevin Beattie
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-06-05 03:58:43 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Trevin Beattie 2001-06-03 11:24:32 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.2-2 i586)

Description of problem:
The log, log10, and log2 functions are all supposed to give a domain error
if the argument is negative (and log1p is supposed to give a domain error
if the argument is less than -1).  log, log10, and log1p do this, but log2
does not.


How reproducible:
Always

Steps to Reproduce:
Compile and run the following code:

#include <errno.h>
#define __USE_ISOC99 1
#include <math.h>
#include <stdio.h>
#include <string.h>

main ()
{
  errno = 0;
  printf ("log(-1) returns %g; ", log (-1));
  printf ("error is %s.\n", strerror (errno));
  if (errno != EDOM)
    printf ("\t(Error should have been %s!)\n", strerror (EDOM));

  errno = 0;
  printf ("log2(-1) returns %g; ", log2 (-1));
  printf ("error is %s.\n", strerror (errno));
  if (errno != EDOM) {
    printf ("\t(Error should have been %s!)\n", strerror (EDOM));
    return 1;
  }
  return 0;
}


Actual Results:  log(-1) returns nan; error is Numerical argument out of
domain.
log2(-1) returns nan; error is Success.
	(Error should have been Numerical argument out of domain!)


Expected Results:  log(-1) returns nan; error is Numerical argument out of
domain.
log2(-1) returns nan; error is Numerical argument out of domain.


Additional info:

Since log2 is relatively new to the C standard, the implementor may not
have gotten around to making it conform yet.  WG14/N869 7.12.6.10 reads:

2	"The log2 functions compute the base-2 logarithm of x.  A domain error
occurs if the argument is less than zero.  A range error may occur if the
argument is zero."

A fix will probably require a wrapper function.
Comment 2 Jakub Jelinek 2001-06-07 09:18:33 EDT
Included in glibc-2.2.3-11.

Note You need to log in before you can comment on or make changes to this bug.