This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/18242] New: powf, powl, do not conform to POSIX for (0, -INFINITY) input


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]