public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/110145] 20_util/to_chars/double.cc fails for -m32 -fexcess-precision=standard
Date: Wed, 07 Jun 2023 17:28:11 +0000	[thread overview]
Message-ID: <bug-110145-4-KcL3MfmoY1@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110145-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110145

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:88e7f1f7ee67462713a89104ae07e99b191d5e2c

commit r14-1619-g88e7f1f7ee67462713a89104ae07e99b191d5e2c
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jun 7 19:27:35 2023 +0200

    libstdc++: Fix up 20_util/to_chars/double.cc test for excess precision
[PR110145]

    This test apparently contains 3 problematic floating point constants,
    1e126, 4.91e-6 and 5.547e-6.  These constants suffer from double rounding
    when -fexcess-precision=standard evaluates double constants in the
precision
    of Intel extended 80-bit long double.
    As written in the PR, e.g. the first one is
    0x1.7a2ecc414a03f7ff6ca1cb527787b130a97d51e51202365p+418
    in the precision of GCC's internal format, 80-bit long double has
    63-bit precision, so the above constant rounded to long double is
    0x1.7a2ecc414a03f800p+418L
    (the least significant bit in the 0 before p isn't there already).
    0x1.7a2ecc414a03f800p+418L rounded to IEEE double is
    0x1.7a2ecc414a040p+418.
    Now, if excess precision doesn't happen and we round the GCC's internal
    format number directly to double, it is
    0x1.7a2ecc414a03fp+418 and that is the number the test expects.
    One can see it on x86-64 (where excess precision to long double doesn't
    happen) where double(1e126L) != 1e126.
    The other two constants suffer from the same problem.

    The following patch tweaks the testcase, such that those problematic
    constants are used only if FLT_EVAL_METHOD is 0 or 1 (i.e. when we have
    guarantee the constants will be evaluated in double precision),
    plus adds corresponding tests with hexadecimal constants which don't
    suffer from this excess precision problem, they are exact in double
    and long double can hold all double values.

    2023-06-07  Jakub Jelinek  <jakub@redhat.com>

            PR libstdc++/110145
            * testsuite/20_util/to_chars/double.cc: Include <cfloat>.
            (double_to_chars_test_cases,
            double_scientific_precision_to_chars_test_cases_2,
            double_fixed_precision_to_chars_test_cases_2): #if out 1e126,
4.91e-6
            and 5.547e-6 tests if FLT_EVAL_METHOD is negative or larger than 1.
            Add unconditional tests with corresponding double constants
            0x1.7a2ecc414a03fp+418, 0x1.4981285e98e79p-18 and
            0x1.7440bbff418b9p-18.

  parent reply	other threads:[~2023-06-07 17:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 16:20 [Bug libstdc++/110145] New: " redi at gcc dot gnu.org
2023-06-06 16:34 ` [Bug libstdc++/110145] " jakub at gcc dot gnu.org
2023-06-06 16:40 ` redi at gcc dot gnu.org
2023-06-06 17:06 ` jakub at gcc dot gnu.org
2023-06-07  9:12 ` jakub at gcc dot gnu.org
2023-06-07  9:42 ` jakub at gcc dot gnu.org
2023-06-07  9:50 ` jakub at gcc dot gnu.org
2023-06-07 13:49 ` jakub at gcc dot gnu.org
2023-06-07 17:28 ` cvs-commit at gcc dot gnu.org [this message]
2023-06-09 12:21 ` redi at gcc dot gnu.org
2023-07-27  9:26 ` rguenth at gcc dot gnu.org
2024-05-21  9:15 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-110145-4-KcL3MfmoY1@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).