public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101061] tree-vrp misoptimization on skylake+ using union-based aliasing
Date: Tue, 15 Jun 2021 16:20:42 +0000	[thread overview]
Message-ID: <bug-101061-4-0JKZmqvpc9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101061-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> ---
On June 15, 2021 4:27:37 PM GMT+02:00, "alexander.grund@tu-dresden.de"
<gcc-bugzilla@gcc.gnu.org> wrote:
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101061
>
>--- Comment #6 from Alexander Grund <alexander.grund@tu-dresden.de> ---
>Oh and for completeness: The same applies to the following union,
>doesn't it?
>I.e. given this:
>
>struct TF_TString_Raw {
>  uint8_t raw[24];
>};
>struct TF_TString_Small {
>  uint8_t size;
>  char str[23];
>};
>struct TF_TString_Large { 
>  size_t size;
>  size_t cap;
>  char *ptr;
>};
>union{
>    TF_TString_Raw raw;
>    TF_TString_Small smll;
>    TF_TString_Large large;
>} x;  
>
>it is not allowed to access x.raw.raw[0] AND then x.large.size (not
>even a
>common initial subsequence) but also not x.raw.raw[0] AND then
>x.small.size
>(maybe a common sequence, not sure about the array, but not implemented
>in GCC)

Note that when the union type is visible in the access path then GCC allows
punning without further restrictions. Thus the accesses as written above are
OK. What is not OK is mixed accesses via pointers to the small/large/base
aggregate types. What is OK is accesses via an effective character type
(uint8_t is usually as implementation detail, not sure if by the standard),
thus char *

  parent reply	other threads:[~2021-06-15 16:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14 10:39 [Bug tree-optimization/101061] New: " alexander.grund@tu-dresden.de
2021-06-14 10:40 ` [Bug tree-optimization/101061] " alexander.grund@tu-dresden.de
2021-06-15  7:31 ` rguenth at gcc dot gnu.org
2021-06-15 12:51 ` alexander.grund@tu-dresden.de
2021-06-15 13:02 ` rguenther at suse dot de
2021-06-15 14:21 ` alexander.grund@tu-dresden.de
2021-06-15 14:27 ` alexander.grund@tu-dresden.de
2021-06-15 16:16 ` rguenther at suse dot de
2021-06-15 16:20 ` rguenther at suse dot de [this message]
2021-06-16  6:23 ` alexander.grund@tu-dresden.de
2021-06-16  7:34 ` alexander.grund@tu-dresden.de
2021-06-16  9:46 ` rguenther at suse dot de
2021-06-16  9:54 ` rguenther at suse dot de
2021-06-16 10:11 ` alexander.grund@tu-dresden.de
2021-06-16 11:10 ` rguenther at suse dot de
2021-06-24  7:09 ` rguenth 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-101061-4-0JKZmqvpc9@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).