Bug 43347 - log2(-1) does not set errno
Summary: log2(-1) does not set errno
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libc
Version: 7.1
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-06-03 15:24 UTC by Trevin Beattie
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-06-05 07:58:43 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2001:121 0 normal SHIPPED_LIVE GNU C Library bugfix update 2001-10-04 04:00:00 UTC

Description Trevin Beattie 2001-06-03 15:24:32 UTC
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 13:18:33 UTC
Included in glibc-2.2.3-11.


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