public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jason Merrill <jason@redhat.com>, Martin Jambor <mjambor@suse.cz>,
	Richard Biener <rguenther@suse.de>,
	Iain Buclaw <ibuclaw@gdcproject.org>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: Add __builtin_bit_cast to implement std::bit_cast [PR93121]
Date: Thu, 27 Aug 2020 12:06:59 +0100	[thread overview]
Message-ID: <20200827110659.GS3400@redhat.com> (raw)
In-Reply-To: <20200827104656.GJ2961@tucnak>

On 27/08/20 12:46 +0200, Jakub Jelinek wrote:
>On Thu, Aug 27, 2020 at 12:06:13PM +0200, Jakub Jelinek via Gcc-patches wrote:
>
>Oops, rewrote the testcase from __builtin_bit_cast to std::bit_cast without
>adjusting the syntax properly.
>Also, let's not use bitfields in there, as clang doesn't support those.
>So, adjusted testcase below.  clang++ rejects all 6 of those, but from what
>you said, I'd expect that u and z should be well defined.
>
>#include <bit>
>
>struct S { short a; int b; };
>struct T { int a, b; };
>
>constexpr int
>foo ()
>{
>  S a = S ();
>  S b = { 0, 0 };
>  S c = a;
>  S d;
>  S e;
>  d = a;
>  e = S ();
>  int u = std::bit_cast<T> (a).a; // Is this well defined due to value initialization of a?

The standard says that padding bits in the bit_cast result are
unspecified, so I don't think they have to be copied even if the
source object was zero-initialized and has all-zero padding bits.


  reply	other threads:[~2020-08-27 11:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-18 18:50 Jakub Jelinek
2020-07-22 14:03 ` Paul Koning
2020-07-30 14:16 ` Jason Merrill
2020-07-30 14:57   ` Jakub Jelinek
2020-07-30 21:59     ` Jason Merrill
2020-07-31  8:19       ` Jakub Jelinek
2020-07-31  9:54         ` Jonathan Wakely
2020-07-31 10:06           ` Jakub Jelinek
2020-07-31 20:28             ` Jason Merrill
2020-08-27 10:06               ` Jakub Jelinek
2020-08-27 10:19                 ` Richard Biener
2020-09-02 21:52                   ` Jason Merrill
2020-08-27 10:46                 ` Jakub Jelinek
2020-08-27 11:06                   ` Jonathan Wakely [this message]
2020-08-27 11:17                     ` Jakub Jelinek
2020-08-27 11:22                       ` Jonathan Wakely
2020-08-27 10:59                 ` Jonathan Wakely
2020-08-27 20:43                 ` Iain Buclaw
2020-11-02 19:21   ` [PATCH] c++: v2: " Jakub Jelinek
2020-11-25  0:31     ` Jeff Law
2020-11-25  9:23       ` Jakub Jelinek
2020-11-25 10:31         ` Jonathan Wakely
2020-11-25 16:24           ` Jakub Jelinek
2020-11-25 16:28             ` Jonathan Wakely
2020-11-25 17:26     ` Jason Merrill
2020-11-25 18:50       ` Jakub Jelinek
2020-11-26  0:52         ` Jason Merrill
2020-11-26 15:09           ` [PATCH] c++: v3: " Jakub Jelinek
2020-12-03 14:24             ` Jason Merrill

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=20200827110659.GS3400@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ibuclaw@gdcproject.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.com \
    --cc=mjambor@suse.cz \
    --cc=rguenther@suse.de \
    /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).