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.
See http://sources.redhat.com/ml/libc-hacker/2001-06/msg00002.html
Included in glibc-2.2.3-11.