This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/18242] New: powf, powl, do not conform to POSIX for (0, -INFINITY) input
- From: "nszabolcs at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Fri, 10 Apr 2015 12:04:28 +0000
- Subject: [Bug math/18242] New: powf, powl, do not conform to POSIX for (0, -INFINITY) input
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=18242
Bug ID: 18242
Summary: powf, powl, do not conform to POSIX for (0, -INFINITY)
input
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: math
Assignee: unassigned at sourceware dot org
Reporter: nszabolcs at gmail dot com
posix seems to require pow(0, -INFINITY) to raise divbyzero flag.
ISO C Annex F:
pow((+-)0, -(inf)) returns +(inf) and may raise the ''divide-by-zero''
floating-point exception.
http://port70.net/~nsz/c/c11/n1570.html#F.10.4.4
but
POSIX-2008 (2013):
On systems that support the IEC 60559 Floating-Point option, if x is Â0,
a pole error shall occur and pow(), powf(), and powl() shall return
ÂHUGE_VAL, ÂHUGE_VALF, and ÂHUGE_VALL, respectively if y is an odd
integer, or HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively if y is not
an odd integer.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pow.html
#define _POSIX_C_SOURCE 200809L
#include <fenv.h>
#include <math.h>
#include <stdio.h>
int main()
{
#pragma STDC FENV_ACCESS ON
powf(0, -INFINITY);
if (!fetestexcept(FE_DIVBYZERO))
printf("powf did not raise div by zero flag.\n");
feclearexcept(FE_ALL_EXCEPT);
// this one works correctly
pow(0, -INFINITY);
if (!fetestexcept(FE_DIVBYZERO))
printf("pow did not raise div by zero flag.\n");
feclearexcept(FE_ALL_EXCEPT);
powl(0, -INFINITY);
if (!fetestexcept(FE_DIVBYZERO))
printf("powl did not raise div by zero flag.\n");
}
--
You are receiving this mail because:
You are on the CC list for the bug.