public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/111097] mistifying bug triggered by trivial code change
Date: Tue, 22 Aug 2023 09:41:13 +0000	[thread overview]
Message-ID: <bug-111097-4-HiCVKfkNyp@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111097-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Fabio Cannizzo from comment #3)
> Using -fno-strict-aliasing the issue disappear, however I am not sure if
> that is a real fix, or if it is merely circumstantial.

When creating the bug report there was a notice at the top of the page:

"Before reporting that GCC compiles your code incorrectly, compile it with gcc
-Wall -Wextra and see whether this shows anything wrong with your code.
Similarly, if compiling with -fno-strict-aliasing -fwrapv makes a difference,
your code probably is not correct."

That is the case here.

> As mentioned, there are many other possible workarounds which also make the
> issue disappear. The most curious one being the one below, where p has type
> __m128i*, and simply casting it to XV* before the assignment, things stop
> working.

Yes, code with undefined behaviour is fragile and unpredictable.

> Worth noting, this code works correctly with Visual Studio and with clang.

Yes. code with undefined behaviour sometimes appears to work correctly with
different compilers, or just with different optimizations enabled.

  parent reply	other threads:[~2023-08-22  9:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-22  6:47 [Bug c++/111097] New: " fabio at cannizzo dot net
2023-08-22  6:58 ` [Bug c++/111097] " fabio at cannizzo dot net
2023-08-22  7:14 ` rguenth at gcc dot gnu.org
2023-08-22  7:42 ` fabio at cannizzo dot net
2023-08-22  7:49 ` pinskia at gcc dot gnu.org
2023-08-22  7:51 ` pinskia at gcc dot gnu.org
2023-08-22  9:41 ` redi at gcc dot gnu.org [this message]
2023-08-22 11:00 ` fabio at cannizzo dot net

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