Bug 4069 - pow(-inf, nan) gives inf instead of nan
Summary: pow(-inf, nan) gives inf instead of nan
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-18 22:47 UTC by Aurelien Jarno
Modified: 2015-01-29 13:32 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2007-02-18 22:47:54 UTC
Here is a simple testcase:

[ampere:/tmp]$ cat test.c
#include <math.h>
#include <stdio.h>

int main()
{
  printf("%lf\n", pow(-INFINITY, NAN));
  return 0;
}
[ampere:/tmp]$ gcc -o test test.c -std=c99 -lm
[ampere:/tmp]$ ./test
inf

Note that the problem is present on x86_64 and powerpc, but not on i386.
Comment 1 Jakub Jelinek 2007-03-01 15:19:59 UTC
Testing a patch.
Comment 3 Ulrich Drepper 2007-03-05 19:40:32 UTC
Fixed in cvs.
Comment 4 Sourceware Commits 2007-07-12 14:58:16 UTC
Subject: Bug 4069

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	glibc-2_5-branch
Changes by:	jakub@sourceware.org	2007-07-12 14:58:06

Modified files:
	.              : ChangeLog 
	math           : libm-test.inc 
	sysdeps/i386/fpu: e_pow.S e_powf.S e_powl.S 
	sysdeps/ieee754/dbl-64: e_pow.c 
	sysdeps/x86_64/fpu: e_powl.S 

Log message:
	2007-03-01  Jakub Jelinek  <jakub@redhat.com>
	
	[BZ #4069]
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Check for NaN
	earlier.
	* math/libm-test.inc (pow_test): Add more tests involving NaNs.
	
	* sysdeps/i386/fpu/e_powf.S (__ieee754_powf): Avoid invalid exception
	for x qNaN and y either +-inf or non-integer value.
	* sysdeps/i386/fpu/e_pow.S (__ieee754_pow): Likewise.
	* sysdeps/i386/fpu/e_powl.S (__ieee754_powl): Likewise.
	* sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/ChangeLog.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.10362.2.50&r2=1.10362.2.51
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/math/libm-test.inc.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.73&r2=1.73.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/i386/fpu/e_pow.S.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.7&r2=1.7.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/i386/fpu/e_powf.S.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.7&r2=1.7.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/i386/fpu/e_powl.S.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.7&r2=1.7.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/dbl-64/e_pow.c.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.13&r2=1.13.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/x86_64/fpu/e_powl.S.diff?cvsroot=glibc&only_with_tag=glibc-2_5-branch&r1=1.2&r2=1.2.8.1