public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Filippo Bistaffa <filippo.bistaffa@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: float is constructible from double, C++23's std::float13_t is not
Date: Fri, 24 Mar 2023 20:22:08 +0000	[thread overview]
Message-ID: <CAH6eHdS9JZ6X_rk5kHDchFM2g-XfWDdH0Pw9FQT1XxRRGWescw@mail.gmail.com> (raw)
In-Reply-To: <CANuktPp9UTyrmS=VUYkXNrVghVpo7V2utkqZ0fuwPY6GC6bgHQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1155 bytes --]

On Fri, 24 Mar 2023, 17:05 Filippo Bistaffa via Gcc-help, <
gcc-help@gcc.gnu.org> wrote:

> I was playing around with gcc-trunk's support for C++23's std::float13_t
> and I found out that, while float is constructible from double, as far as I
> can tell std::float13_t is not.
> In other words, the following code compiles OK:
>
> #include <stdfloat>
> #include <vector>
> int main() {
>     std::vector<double> x(5);
>     std::vector<float> y(std::begin(x), std::end(x));
> }
>
> whereas the following does not:
>
> #include <stdfloat>
> #include <vector>
> int main() {
>     std::vector<double> x(5);
>     std::vector<std::float16_t> y(std::begin(x), std::end(x));
> }
>
> See this snippet <https://godbolt.org/z/zq7KdhY44>.
> Am I missing something or is it supposed to be like that?
>

Yes, this is the correct behaviour. The C++23 standard says:

"A prvalue of floating-point type can be converted to a prvalue of another
floating-point type with a greater or equal conversion rank ([conv.rank]
<https://eel.is/c++draft/conv.rank>).
A prvalue of standard floating-point type can be converted to a prvalue of
another standard floating-point type."

  reply	other threads:[~2023-03-24 20:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 17:04 Filippo Bistaffa
2023-03-24 20:22 ` Jonathan Wakely [this message]
2023-03-25 11:29   ` Filippo Bistaffa
2023-03-25 11:58     ` 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=CAH6eHdS9JZ6X_rk5kHDchFM2g-XfWDdH0Pw9FQT1XxRRGWescw@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=filippo.bistaffa@gmail.com \
    --cc=gcc-help@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).