public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: Jonathan Wakely <jwakely@redhat.com>,
	"libstdc++" <libstdc++@gcc.gnu.org>,
	 gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] libstdc++: Ensure that std::from_chars is declared when supported
Date: Mon, 14 Mar 2022 21:15:34 +0000	[thread overview]
Message-ID: <CAH6eHdTjPC9mrikbjxOqpg5QAnjE=JHBpaBsHT3P62k6w-Cc9g@mail.gmail.com> (raw)
In-Reply-To: <d3a7cc04-b15a-0829-f2df-7935a2513818@idea>

On Mon, 14 Mar 2022 at 14:17, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> On Fri, 11 Mar 2022, Jonathan Wakely wrote:
>
> > Patrick, I think this is right, but please take a look to double check.
> >
> > I think we should fix the feature-test macro conditions for gcc-11 too,
> > although it's a bit more complicated there. It should depend on IEEE
> > float and double *and* uselocale. We don't need the other changes on the
> > branch.
>
> Don't we still depend on uselocale in GCC 12 for long double from_chars,
> at least on targets where long double != binary64?

Not after this patch:

from_chars(const char* first, const char* last, long double& value,
          chars_format fmt) noexcept
{
-#if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 \
-  && ! USE_STRTOD_FOR_FROM_CHARS
+#if ! USE_STRTOD_FOR_FROM_CHARS
+  // Either long double is the same as double, or we can't use strtold.
+  // In the latter case, this might give an incorrect result (e.g. values
+  // out of range of double give an error, even if they fit in long double).

If uselocale isn't available, this defines the long double overload in
terms of the double one, even if that doesn't always give the right
answers. That greatly simplifies the preprocessor conditions for when
it's supported. If the float and double forms are present, so is the
long double one.

  reply	other threads:[~2022-03-14 21:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 18:32 Jonathan Wakely
2022-03-14 14:15 ` Patrick Palka
2022-03-14 21:15   ` Jonathan Wakely [this message]
2022-03-15 14:12     ` Patrick Palka
2022-03-16 16:26       ` Jonathan Wakely
2022-03-16 16:54   ` Jonathan Wakely

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='CAH6eHdTjPC9mrikbjxOqpg5QAnjE=JHBpaBsHT3P62k6w-Cc9g@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /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).