From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 54B2B385734D; Wed, 29 Jun 2022 02:36:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54B2B385734D From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106131] -fstrict-aliasing breaks normal program that does not use any pointer or reference Date: Wed, 29 Jun 2022 02:36:41 +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: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 02:36:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106131 --- Comment #2 from Andrew Pinski --- Here is a slightly reduced (still has std::vector in it): #include template struct Pair1 { constexpr Pair1(const Pair1&) =3D default; constexpr Pair1(Pair1&&) =3D default; constexpr Pair1(const A& __a, const B& __b) : first(__a), second(__b) { } Pair1& operator=3D( const Pair1 & __p) { first =3D __p.first; second =3D __p.second; return *this; } A first; B second; }; typedef Pair1 Pair; std::vector f =3D {{0, -11}, {0, -8}, {1, 2}}; int foo(Pair x, Pair y) { return std::max(x.second, y.second); } int main() { int t =3D 0; for (int J =3D 0; J < 1; J++) { f[J] =3D f[0]; if(J =3D=3D 0) f[J] =3D f[2]; t =3D foo(f[J], f[1]); } if (t !=3D 2) __builtin_abort(); }=