From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6907F3858C2A; Tue, 22 Aug 2023 09:41:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6907F3858C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692697275; bh=RhkHSUAaw7ApJ1qLLz1HvvvOa17N9j+6SkwFIAP4WZw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cSL2SHnZiSHi3d56WOwoI2PpN8MyJNeRD6ge7KLZoce54x6R/nokzA15yQ3kOOSA7 d2cwVuixcqe6T5upkQOuiULZJRxGj0HDLNWjklYejcxcjwkYdM/I0q1ivNiUlyhP7+ TVzk2xS3YLY1d8fND1l9bG3uv3P3UMob1Z+/d6Ck= From: "redi at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111097 --- Comment #6 from Jonathan Wakely --- (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 differenc= e, your code probably is not correct." That is the case here. > As mentioned, there are many other possible workarounds which also make t= he > issue disappear. The most curious one being the one below, where p has ty= pe > __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.=