public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/16677] New: nextafter incorrect in directed rounding modes
@ 2014-03-08  0:52 jsm28 at gcc dot gnu.org
  2014-03-08 14:09 ` [Bug math/16677] " cvs-commit at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2014-03-08  0:52 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 16677
           Summary: nextafter incorrect in directed rounding modes
           Product: glibc
           Version: 2.19
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: jsm28 at gcc dot gnu.org

At least some nextafter implementations compute an overflowing result as x + x
to raise the overflow exception.  However, the result must be independent of
the rounding mode (C11 F.10.8.3); the exception is correct, the finite value in
some rounding modes isn't.  E.g., on x86_64 for float:

testing float (without inline functions)
Failure: Test: nextafter_downward (max_value, inf)
Result:
 is:          3.40282346638528859811e+38   0x1.fffffe00000000000000p+127
 should be:   inf   inf
Failure: Test: nextafter_towardzero (max_value, inf)
Result:
 is:          3.40282346638528859811e+38   0x1.fffffe00000000000000p+127
 should be:   inf   inf
Failure: Test: nextafter_towardzero (-max_value, -inf)
Result:
 is:         -3.40282346638528859811e+38  -0x1.fffffe00000000000000p+127
 should be:  -inf  -inf
Failure: Test: nextafter_upward (-max_value, -inf)
Result:
 is:         -3.40282346638528859811e+38  -0x1.fffffe00000000000000p+127
 should be:  -inf  -inf

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


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

* [Bug math/16677] nextafter incorrect in directed rounding modes
  2014-03-08  0:52 [Bug math/16677] New: nextafter incorrect in directed rounding modes jsm28 at gcc dot gnu.org
@ 2014-03-08 14:09 ` cvs-commit at gcc dot gnu.org
  2014-03-11 22:25 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-03-08 14:09 UTC (permalink / raw)
  To: glibc-bugs

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

--- 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  e9996ef750d845b46bc7d743c730c73f044720af (commit)
      from  5c7808498e9e1fd3df43aa2bd84fd47dc8e6ab7c (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=e9996ef750d845b46bc7d743c730c73f044720af

commit e9996ef750d845b46bc7d743c730c73f044720af
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Sat Mar 8 14:08:38 2014 +0000

    Add libm-test.inc macro for all-rounding-modes testing.

    This patch adds support in libm-test.inc for automatically running
    tests of a function in all rounding modes, in the form of a macro
    ALL_RM_TEST to loop over all rounding modes when running tests of a
    function, and uses it for functions whose results should always be
    independent of the rounding mode.

    Conversion of tests of nextafter to ALL_RM_TEST was deferred because
    trying that conversion showed up bug 16677.  (Finding such a bug of
    course illustrates the point of testing more systematically in all
    rounding modes rather than only reactively when bugs get reported in a
    particular function in a non-default mode.)  Conversion of tests where
    results can depend on the rounding mode will follow once I add
    gen-libm-test.pl support for using different initializers for the
    expected results for different rounding modes (again, some conversions
    may need deferring until bugs are fixed, depending on how
    straightforward they are to XFAIL in a particular context).

    Some existing tests get run five times rather than four, with
    round-to-nearest tests both run in that as default rounding mode and
    also with it explicitly set with fesetround (FE_TONEAREST).  This
    duplication doesn't seem particularly useful, so ALL_RM_TEST only runs
    tests four times.

    Tested x86_64 and x86.

        * math/libm-test.inc (ALL_RM_TEST): New macro.
        (ceil_test): Use ALL_RM_TEST.
        (cimag_test): Likewise.
        (conj_test): Likewise.
        (copysign_test): Likewise.
        (cproj_test): Likewise.
        (creal_test): Likewise.
        (fabs_test): Likewise.
        (floor_test): Likewise.
        (fmax_test): Likewise.
        (fmin_test): Likewise.
        (fmod_test): Likewise.
        (fpclassify_test): Likewise.
        (frexp_test): Likewise.
        (ilogb_test): Likewise.
        (isfinite_test): Likewise.
        (finite_test): Likewise.
        (isgreater_test): Likewise.
        (isgreaterequal_test): Likewise.
        (isinf_test): Likewise.
        (isless_test): Likewise.
        (islessequal_test): Likewise.
        (islessgreater_test): Likewise.
        (isnan_test): Likewise.
        (isnormal_test): Likewise.
        (issignaling_test): Likewise.
        (isunordered_test): Likewise.
        (logb_test): Likewise.
        (logb_downward_test_data): Remove.
        (logb_test_downward): Likewise.
        (lround_test): Use ALL_RM_TEST.
        (llround_test): Likewise.
        (modf_test): Likewise.
        (nexttoward_test): Likewise.
        (remainder_test): Likewise.
        (drem_test): Likewise.
        (remainder_tonearest_test_data): Likewise.
        (remainder_test_tonearest): Likewise.
        (drem_test_tonearest): Likewise.
        (remainder_towardzero_test_data): Likewise.
        (remainder_test_towardzero): Likewise.
        (drem_test_towardzero): Likewise.
        (remainder_downward_test_data): Likewise.
        (remainder_test_downward): Likewise.
        (drem_test_downward): Likewise.
        (remainder_upward_test_data): Likewise.
        (remainder_test_upward): Likewise.
        (drem_test_upward): Likewise.
        (remquo_test): Use ALL_RM_TEST.  Remove comment about x.
        (round_test): Use ALL_RM_TEST.
        (signbit_test): Likewise.
        (trunc_test): Likewise.
        (significand_test): Likewise.
        (main): Don't call removed functions.

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

Summary of changes:
 ChangeLog          |   57 ++++++++
 math/libm-test.inc |  398 ++++++++++------------------------------------------
 2 files changed, 130 insertions(+), 325 deletions(-)

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


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

* [Bug math/16677] nextafter incorrect in directed rounding modes
  2014-03-08  0:52 [Bug math/16677] New: nextafter incorrect in directed rounding modes jsm28 at gcc dot gnu.org
  2014-03-08 14:09 ` [Bug math/16677] " cvs-commit at gcc dot gnu.org
@ 2014-03-11 22:25 ` cvs-commit at gcc dot gnu.org
  2014-03-11 22:25 ` jsm28 at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-03-11 22:25 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 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  600fa36158cd741d897b2d22c735c60247b982e0 (commit)
      from  d7706c32589ef32f4bed3122a2f5c861b214149e (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=600fa36158cd741d897b2d22c735c60247b982e0

commit 600fa36158cd741d897b2d22c735c60247b982e0
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Mar 11 22:24:00 2014 +0000

    Fix nextafter overflow in non-default rounding modes (bug 16677).

    ISO C requires the result of nextafter to be independent of the
    rounding mode, even when underflow or overflow occurs.  This patch
    fixes the bug in various nextafter implementations that, having done
    an overflowing computation to force an overflow exception (correct),
    they then return the result of that computation rather than an
    infinity computed some other way (incorrect, when the overflowing
    result of arithmetic with that sign and rounding mode is finite but
    the correct result is infinite) - generally by falling through to
    existing code to return a value that in fact is correct for this case
    (but was computed by an integer increment and so without generating
    the exceptions required).  Having fixed the bug, the previously
    deferred conversion of nextafter testing in libm-test.inc to
    ALL_RM_TEST is also included.

    Tested x86_64 and x86; also spot-checked results of nextafter tests
    for powerpc32 and mips64 to test the ldbl-128ibm and ldbl-128
    changes.  (The m68k change is untested.)

        [BZ #16677]
        * math/s_nextafter.c (__nextafter): Do not return value from
        overflowing computation.
        * sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Likewise.
        * sysdeps/ieee754/flt-32/s_nextafterf.c (__nextafterf): Likewise.
        * sysdeps/ieee754/ldbl-128/s_nextafterl.c (__nextafterl):
        Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl):
        Likewise.
        * sysdeps/m68k/m680x0/fpu/s_nextafterl.c (__nextafterl): Likewise.
        * math/libm-test.inc (nextafter_test): Use ALL_RM_TEST.

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

Summary of changes:
 ChangeLog                                  |   14 ++++++++++++++
 NEWS                                       |    2 +-
 math/libm-test.inc                         |    5 +----
 math/s_nextafter.c                         |    6 ++----
 sysdeps/i386/fpu/s_nextafterl.c            |    5 ++++-
 sysdeps/ieee754/flt-32/s_nextafterf.c      |    6 ++----
 sysdeps/ieee754/ldbl-128/s_nextafterl.c    |    5 ++++-
 sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c |   14 ++++++++++----
 sysdeps/m68k/m680x0/fpu/s_nextafterl.c     |    5 ++++-
 9 files changed, 42 insertions(+), 20 deletions(-)

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


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

* [Bug math/16677] nextafter incorrect in directed rounding modes
  2014-03-08  0:52 [Bug math/16677] New: nextafter incorrect in directed rounding modes jsm28 at gcc dot gnu.org
  2014-03-08 14:09 ` [Bug math/16677] " cvs-commit at gcc dot gnu.org
  2014-03-11 22:25 ` cvs-commit at gcc dot gnu.org
@ 2014-03-11 22:25 ` jsm28 at gcc dot gnu.org
  2014-06-13  6:36 ` fweimer at redhat dot com
  2015-10-02 17:12 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2014-03-11 22:25 UTC (permalink / raw)
  To: glibc-bugs

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

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

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

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

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


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

* [Bug math/16677] nextafter incorrect in directed rounding modes
  2014-03-08  0:52 [Bug math/16677] New: nextafter incorrect in directed rounding modes jsm28 at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-03-11 22:25 ` jsm28 at gcc dot gnu.org
@ 2014-06-13  6:36 ` fweimer at redhat dot com
  2015-10-02 17:12 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13  6:36 UTC (permalink / raw)
  To: glibc-bugs

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

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


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

* [Bug math/16677] nextafter incorrect in directed rounding modes
  2014-03-08  0:52 [Bug math/16677] New: nextafter incorrect in directed rounding modes jsm28 at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2014-06-13  6:36 ` fweimer at redhat dot com
@ 2015-10-02 17:12 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-10-02 17:12 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #5 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  59a63cca1133a8e1e3219970ee95979ac1f810df (commit)
      from  ef6b619f73e49b6d87c7530e6e9f8a59723b492d (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=59a63cca1133a8e1e3219970ee95979ac1f810df

commit 59a63cca1133a8e1e3219970ee95979ac1f810df
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Fri Oct 2 17:11:13 2015 +0000

    Fix nexttoward overflow in non-default rounding modes (bug 19059).

    ISO C requires overflowing results from nexttoward to be the
    appropriate infinity independent of the rounding mode, but some
    implementations use a rounding-mode-dependent result (this is the same
    issue as was fixed for nextafter in bug 16677).  This patch fixes the
    problem by making the nexttoward implementations discard the result
    from the floating-point computation that forced an overflow exception
    and then return the infinity previously computed with integer
    arithmetic.

    Tested for x86_64, x86, mips64 and powerpc.

        [BZ #19059]
        * math/s_nexttowardf.c (__nexttowardf): Do not return value from
        overflowing computation.
        * sysdeps/i386/fpu/s_nexttoward.c (__nexttoward): Likewise.
        * sysdeps/i386/fpu/s_nexttowardf.c (__nexttowardf): Likewise.
        * sysdeps/ieee754/ldbl-128/s_nexttoward.c (__nexttoward):
        Likewise.
        * sysdeps/ieee754/ldbl-128/s_nexttowardf.c (__nexttowardf):
        Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c (__nexttoward):
        Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf):
        Likewise.
        * sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Likewise.
        * sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf):
        Likewise.
        * sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c (__nldbl_nexttowardf):
        Likewise.
        * math/libm-test.inc (nexttoward_test_data): Add more tests.

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

Summary of changes:
 ChangeLog                                   |   20 ++++++++++++++++++++
 NEWS                                        |    2 +-
 math/libm-test.inc                          |    4 ++++
 math/s_nexttowardf.c                        |    4 ++--
 sysdeps/i386/fpu/s_nexttoward.c             |    4 ++--
 sysdeps/i386/fpu/s_nexttowardf.c            |    4 ++--
 sysdeps/ieee754/ldbl-128/s_nexttoward.c     |    4 ++--
 sysdeps/ieee754/ldbl-128/s_nexttowardf.c    |    5 ++++-
 sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c  |    4 ++--
 sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c |    4 ++--
 sysdeps/ieee754/ldbl-96/s_nexttoward.c      |    4 ++--
 sysdeps/ieee754/ldbl-96/s_nexttowardf.c     |    4 ++--
 sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c   |    4 ++--
 13 files changed, 47 insertions(+), 20 deletions(-)

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


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

end of thread, other threads:[~2015-10-02 17:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-08  0:52 [Bug math/16677] New: nextafter incorrect in directed rounding modes jsm28 at gcc dot gnu.org
2014-03-08 14:09 ` [Bug math/16677] " cvs-commit at gcc dot gnu.org
2014-03-11 22:25 ` cvs-commit at gcc dot gnu.org
2014-03-11 22:25 ` jsm28 at gcc dot gnu.org
2014-06-13  6:36 ` fweimer at redhat dot com
2015-10-02 17:12 ` cvs-commit 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).