public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/107815] 20_util/to_chars/float128_c++23.cc FAILs
Date: Wed, 23 Nov 2022 15:23:54 +0000	[thread overview]
Message-ID: <bug-107815-4-9LYiwovKZn@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107815-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org,
                   |                            |redi at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
You're right.
This is the:
    else if (fmt == chars_format::fixed && fd.exponent >= 0)
      {
        // The Ryu exponent is positive, and so this number's shortest
        // representation is a whole number, to be formatted in fixed instead
        // of scientific notation "as if by std::printf".  This means we may
        // need to print more digits of the IEEE mantissa than what the
        // shortest scientific form given by Ryu provides.
        //
        // For instance, the exactly representable number
        // 12300000000000001048576.0 has as its shortest scientific
        // representation 123e+22, so in this case fd.mantissa is 123 and
        // fd.exponent is 22, which doesn't have enough information to format
        // the number exactly.  So we defer to Ryu's d2fixed_buffered_n with
        // precision=0 to format the number in the general case here.
case for which ryu doesn't handle d2fixed_buffered_n for wider than double and
so use
            const int output_length = sprintf_ld(buffer,
                                                 expected_output_length + 1,
                                                 "%.0Lf", value);
and Solaris apparently violates ISO C99 in producing for the last 3 printf
calls scientifix values rather than fixed:
#include <stdio.h>

int
main ()
{
  printf ("%.0f\n", __DBL_MAX__);
  printf ("%.0Lf\n", (long double) __DBL_MAX__);
  printf ("%.0Lf\n", 2.0L * __DBL_MAX__);
  printf ("%.0Lf\n", 1e+202L * __DBL_MAX__);
  printf ("%.0Lf\n", 1e+203L * __DBL_MAX__);
  printf ("%.0Lf\n", (long double) __DBL_MAX__ * (long double) __DBL_MAX__);
  printf ("%.0Lf\n", __LDBL_MAX__);
}
The 1e+202L * __DBL_MAX__ number is:
1797693134862315708145274237317043363780293901488132670510305396153274401107450252964067353821542098883610426262810674725334159395885309388675990127492090757713383689567223448511120723139743573688679064280172265585993927318314820133831157520860190820700571151387146478495139447053313076754655788391539857757373041885363113533243178943928496535556954517148959372706003524689906194839868952331046086040494963209033312113173876118835007579814542996644987978064090838995977878567921521624960885877081515358704107520
which is 511 bytes long excluding '\0' terminator, so bet they have somewhere
fixed length temporary buffer or what.

Jonathan, shall we just #ifdef out the
std::numeric_limits<std::float128_t>::max()
test in that test for Solaris and maybe HP-UX if it suffers from the same bug?

  parent reply	other threads:[~2022-11-23 15:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-22 13:46 [Bug libstdc++/107815] New: " ro at gcc dot gnu.org
2022-11-22 13:47 ` [Bug libstdc++/107815] " ro at gcc dot gnu.org
2022-11-22 14:28 ` jakub at gcc dot gnu.org
2022-11-22 16:10 ` ro at CeBiTec dot Uni-Bielefeld.DE
2022-11-22 17:22 ` jakub at gcc dot gnu.org
2022-11-23 13:10 ` ro at CeBiTec dot Uni-Bielefeld.DE
2022-11-23 15:23 ` jakub at gcc dot gnu.org [this message]
2022-11-23 15:32 ` redi at gcc dot gnu.org
2022-11-23 15:45 ` jakub at gcc dot gnu.org
2022-11-23 15:58 ` ro at CeBiTec dot Uni-Bielefeld.DE
2022-11-23 16:07 ` jakub at gcc dot gnu.org
2022-11-24  9:03 ` ro at CeBiTec dot Uni-Bielefeld.DE
2022-11-24  9:16 ` jakub at gcc dot gnu.org
2022-11-24  9:38 ` cvs-commit at gcc dot gnu.org
2022-11-24  9:41 ` jakub at gcc dot gnu.org
2022-11-27 20:40 ` dave.anglin at bell dot net
2022-11-27 20:45 ` jakub at gcc dot gnu.org
2022-11-27 21:16 ` dave.anglin at bell dot net
2022-11-28  9:12 ` jakub at gcc dot gnu.org
2022-11-28  9:39 ` jakub at gcc dot gnu.org
2022-11-28 13:04 ` dave.anglin at bell dot net
2023-04-26  6:57 ` rguenth at gcc dot gnu.org
2023-06-09 12:24 ` redi at gcc dot gnu.org
2023-07-27  9:24 ` rguenth at gcc dot gnu.org
2024-05-21  9:13 ` 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-107815-4-9LYiwovKZn@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).