public inbox for
 help / color / mirror / Atom feed
From: Jonathan Wakely <>
To: Jakub Jelinek <>
Subject: Re: [PATCH] libstdc++, v3: Partial library support for std::float{16,32,64,128}_t and std::bfloat16_t
Date: Tue, 18 Oct 2022 10:18:10 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <Y02CFLLygVNSOmL2@tucnak>

On Mon, 17 Oct 2022 at 17:26, Jakub Jelinek <> wrote:
> Hi!
> On Mon, Oct 17, 2022 at 02:07:00PM +0100, Jonathan Wakely wrote:
> > Yes, that's now
> > The current proposed resolution is to just restore the C++20 functions
> > and not provide anything for the new types.
> Ok.
> > > If you want to have <cmath> done in a different way, e.g. the patch
> > > groups a lot of different function overloads by the floating point type,
> > > is that ok or do you want to have them one function at a time for all types,
> > > then next?
> >
> > No, I think this way makes more sense. Otherwise the line count in the
> > file will baloon with all the repeated #if #endif directives.
> Ok, changed.
> I've also changed this in limits and std_abs.h (ditto for
> There is one thing I'm not sure about but can be handled incrementally.
> What exactly is is_iec559 supposed to be?

Nobody really knows. numeric_limits is not well specified.

> Currently for float/double/long double/__float128 it seems to be defined
> to true if the type has Inf, qNaN and denormals.
> For std::float{16,32,64,128}_t even a note in the spec says they are
> true.
> Shall it be true only if the type is actually a IEEE754 type
> (binary16/32/64/128) and false otherwise, or that + the x86 extended type?

I think it makes sense to include _Float64x there too.

> Or if it is IEEE754-like and shall it be true also for
> std::bfloat16_t?

It does have NaNs and Infs, so I suppose if double double sets it to
true, then bfloat16_t could as well. I'm unsure what the right choice
is here though.

> Yet another case is the IBM double double, which has infinities, NaNs
> and denormals, but for that one it is hard to claim it is even IEEE754-like
> (variable precision).

Yeah, I think that has is_iec559 == true which is odd.

> > > I could try to handle <complex> too, but am kind of lost there.
> > > The paper dropped the explicit std::complex specializations, can they stay
> > > around as is and should new overloads be added for the
> > > _Float*/__gnu_cxx::__bfloat16_t types?
> >
> > The explicit specializations can stay, they do no harm.
> Ok.  Shall those specialization also get the P1467 changes for the ctors?
> Shall we also have specializations for the extended floating point types,
> or only conditionally (say when float is binary have _Complex _Float32
> so that we get better code)?

Oh I forgot the primary template doesn't use __complex__ for its data members.

Maybe we want to leave the primary template alone (even though it's
kinda useless for non-FP types) and add a new partial specialization
using concepts to constrain it for FP types:

template<typename _Tp> requires floating_point<_Tp>
class complex;

That would be used for all the new FP types, and we can use
__complex__ in there.
The existing explicit specializations for float/double/longdouble
would be preferred to this new partial specialization. We could
disable them for C++23, or leave them. We can decide that later

> > I can take care of the <complex> changes.
> Ok.
> > > And I/O etc. support is missing, not sure I'm able to handle that and if it
> > > is e.g. possible to keep that support out of, because what
> > > extended floating point types one has on a particular arch could change over
> > > time (I mean e.g. bfloat16_t support or float16_t support can be added
> > > etc.).
> >
> > Yes, I think we can add the I/O functions as always_inline because all
> > they're going to do is convert the argument to float, double, or long
> > double and then call the existing overloads. There will be no new
> > virtual functions.
> >
> > I can take care of that too.
> Thanks.
> Here is an updated patch that I'll test overnight (but can't commit
> until the builtins patch is reviewed as it depends on that;
> well, I could comment out the std::float128_t cmath support if
> long double is not IEEE quad and commit that only once the builtins
> patch is in).

Yes, please comment out the define in os_defines.h for now and push - thanks!

  reply	other threads:[~2022-10-18  9:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27  8:45 [RFC PATCH] libstdc++: Partial library support for std::float{16,32,64,128}_t Jakub Jelinek
2022-10-16 10:20 ` [RFC PATCH] libstdc++, v2: " Jakub Jelinek
2022-10-17 13:07   ` Jonathan Wakely
2022-10-17 16:25     ` [PATCH] libstdc++, v3: Partial library support for std::float{16,32,64,128}_t and std::bfloat16_t Jakub Jelinek
2022-10-18  9:18       ` Jonathan Wakely [this message]
2022-10-17 21:33     ` [RFC PATCH] libstdc++, v2: Partial library support for std::float{16, 32, 64, 128}_t Joseph Myers
2022-10-17 21:45       ` Jonathan Wakely
2022-10-17 21:50       ` Jakub Jelinek

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:

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

  git send-email \
    --in-reply-to='' \ \ \ \ \

* 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).