public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/106389] [11/12/13 Regression] IPA modref breaks Safe Bitfields in C++
Date: Fri, 22 Jul 2022 07:09:10 +0000	[thread overview]
Message-ID: <bug-106389-4-0pPLKHWo81@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106389-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org
          Component|ipa                         |c++

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
There's a similar rule in C and we simply don't implement that - it's a "stupid
rule" given there's no good way to implement it.  Well.  -fno-strict-aliasing.

For GCC the allowed way is to access the common initial sequence through the
_union_ type.  Thus

union U { struct A { int i; } a; struct B { int i; float f; } b; };

union U *p;

p->a.i = 1;
.. = p->b.i;  // OK
B *b = &p->b;
... = b->i; // not OK

IPA modref simply makes this issue more visible (this across function
boundary).

Note the C rule doesn't involve unions but consider

A *a = &p->a;

  a->i = 1;
  ... = b->i;

I read the C++ rule as if that were allowed as well (*a could be inside a
union,
who knows - the union declaration might not even be visible in the TU!).

For the rule to take effect the frontend needs to mark each access that
falls under the rule as to have alias-set zero.

  parent reply	other threads:[~2022-07-22  7:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21 17:21 [Bug ipa/106389] New: " mpolacek at gcc dot gnu.org
2022-07-21 17:23 ` [Bug ipa/106389] [11/12/13 Regression] " mpolacek at gcc dot gnu.org
2022-07-21 17:26 ` mpolacek at gcc dot gnu.org
2022-07-22  7:09 ` rguenth at gcc dot gnu.org [this message]
2022-07-22 12:53 ` [Bug c++/106389] " mpolacek at gcc dot gnu.org
2022-07-24  9:05 ` hubicka at gcc dot gnu.org
2022-07-25  6:20 ` rguenth at gcc dot gnu.org
2023-05-29 10:07 ` [Bug c++/106389] [11/12/13/14 " jakub at gcc dot gnu.org
2023-07-08  1:45 ` pinskia at gcc dot gnu.org
2023-10-30 20:09 ` pinskia 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-106389-4-0pPLKHWo81@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).