public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/18245] New: sqrtl(1.1L) raises the inexact flag
@ 2015-04-10 12:29 nszabolcs at gmail dot com
  2015-06-23 17:27 ` [Bug math/18245] " cvs-commit at gcc dot gnu.org
  2015-06-23 17:28 ` jsm28 at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: nszabolcs at gmail dot com @ 2015-04-10 12:29 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18245

            Bug ID: 18245
           Summary: sqrtl(1.1L) raises the inexact flag
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: nszabolcs at gmail dot com

sqrt should not raise inexact when the result is nan.

the following code prints (x86_64 and aarch64 as well):
sqrtl(-1.1) = nan  invalid=1  inexact=1  want inexact=0


#include <fenv.h>
#include <math.h>
#include <stdio.h>

int main()
{
#pragma STDC FENV_ACCESS ON
long double x = -1.1L;
long double r;

feclearexcept(FE_ALL_EXCEPT);
r = sqrtl(x);
if (fetestexcept(FE_INEXACT))
        printf("sqrtl(%Lg) = %La  invalid=%d  inexact=%d  want inexact=0\n", x,
r, !!fetestexcept(FE_INVALID), !!fetestexcept(FE_INEXACT));
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug math/18245] sqrtl(1.1L) raises the inexact flag
  2015-04-10 12:29 [Bug math/18245] New: sqrtl(1.1L) raises the inexact flag nszabolcs at gmail dot com
@ 2015-06-23 17:27 ` cvs-commit at gcc dot gnu.org
  2015-06-23 17:28 ` jsm28 at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-06-23 17:27 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18245

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  8b1bab5ffa235bc494c33fdbe4c9994202936cfc (commit)
      from  c47ca9647f9b72692e62f94fe468cd5568f49129 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8b1bab5ffa235bc494c33fdbe4c9994202936cfc

commit 8b1bab5ffa235bc494c33fdbe4c9994202936cfc
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Jun 23 17:26:46 2015 +0000

    Fix spurious "inexact" exceptions from __kernel_standard_l (bug 18245, bug
18583).

    __kernel_standard_l converts long double arguments to double for use
    in SVID "struct exception".  This has special-case handling for when
    that conversion would overflow or underflow but the original long
    double function wouldn't.  However, it turns out that "inexact"
    exceptions can be spurious here as well, when the function is exactly
    determined and __kernel_standard_l is being called for a domain error.
    This patch fixes this by using feholdexcept / fesetenv to avoid
    exceptions from the conversion, replacing the previous special-case
    logic for overflow and underflow (this covers all functions using
    __kernel_standard_l, not just those that actually need a change, since
    there doesn't seem to be much point in restricting things just to the
    functions that mustn't get "inexact" here).

    Tested for x86_64 and x86.

        [BZ #18245]
        [BZ #18583]
        * sysdeps/ieee754/k_standardl.c: Include <fenv.h>.
        (__kernel_standard_l): Use feholdexcept and fesetenv around
        conversion to double instead of special-casing overflow and
        underflow.
        * math/libm-test.inc (fmod_test_data): Add more tests.
        (remainder_test_data): Likewise.
        (sqrt_test_data): Likewise.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                     |   12 ++++++++++++
 NEWS                          |   12 ++++++------
 math/libm-test.inc            |    9 +++++++++
 sysdeps/ieee754/k_standardl.c |   34 +++++++++-------------------------
 4 files changed, 36 insertions(+), 31 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug math/18245] sqrtl(1.1L) raises the inexact flag
  2015-04-10 12:29 [Bug math/18245] New: sqrtl(1.1L) raises the inexact flag nszabolcs at gmail dot com
  2015-06-23 17:27 ` [Bug math/18245] " cvs-commit at gcc dot gnu.org
@ 2015-06-23 17:28 ` jsm28 at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-06-23 17:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18245

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Joseph Myers <jsm28 at gcc dot gnu.org> ---
Fixed for 2.22.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-23 17:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-10 12:29 [Bug math/18245] New: sqrtl(1.1L) raises the inexact flag nszabolcs at gmail dot com
2015-06-23 17:27 ` [Bug math/18245] " cvs-commit at gcc dot gnu.org
2015-06-23 17:28 ` jsm28 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).