public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bugdal at aerifal dot cx" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/107115] New: Wrong codegen from TBAA under stores that change effective type?
Date: Sat, 01 Oct 2022 20:00:39 +0000	[thread overview]
Message-ID: <bug-107115-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107115
           Summary: Wrong codegen from TBAA under stores that change
                    effective type?
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx
  Target Milestone: ---

Created attachment 53648
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53648&action=edit
original test case by supercat

The attached test case is from user supercat on Stack Overflow (original
source:
https://stackoverflow.com/questions/42178179/will-casting-around-sockaddr-storage-and-sockaddr-in-break-strict-aliasing/42178347?noredirect=1#comment130510083_42178347,
https://godbolt.org/z/jfv1Ge6v4) and demonstrates what appears to be wrong TBAA
optimization on an object with allocated storage whose effective type changes
under stores. It was first presented as another example of this kind of problem
alongside the example that became
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107107, but it seems likely that
the root cause is distinct.

Reportedly clang/LLVM also transforms this example wrong.

On 64-bit targets, the test program outputs 2/1 with optimization levels that
enable -fstrict-aliasing. The expected output is 2/2. Using
-fno-strict-aliasing fixes it.

             reply	other threads:[~2022-10-01 20:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01 20:00 bugdal at aerifal dot cx [this message]
2022-10-01 23:34 ` [Bug rtl-optimization/107115] " pinskia at gcc dot gnu.org
2022-10-01 23:51 ` [Bug middle-end/107115] " pinskia at gcc dot gnu.org
2022-10-06  9:44 ` rguenth at gcc dot gnu.org
2022-10-06 12:20 ` cvs-commit at gcc dot gnu.org
2022-10-06 12:24 ` rguenth at gcc dot gnu.org
2022-10-06 15:19 ` amonakov at gcc dot gnu.org
2022-10-06 15:32 ` jakub at gcc dot gnu.org
2022-10-06 15:39 ` amonakov at gcc dot gnu.org
2022-10-06 19:04 ` pinskia at gcc dot gnu.org
2022-10-07  7:41 ` rguenth at gcc dot gnu.org
2022-10-07  7:44 ` rguenth at gcc dot gnu.org
2022-10-07 13:19 ` amonakov at gcc dot gnu.org
2022-12-27 22:19 ` gabravier at gmail dot com
2022-12-27 22:21 ` gabravier at gmail dot com

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-107115-4@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).