From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 938F33857C6A; Thu, 14 Oct 2021 18:00:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 938F33857C6A From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/93934] Unnecessary fld of uninitialized float stack variable results in ub of valid C++ code Date: Thu, 14 Oct 2021 18:00:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 7.4.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak at gmail dot com X-Bugzilla-Status: NEW 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: Thu, 14 Oct 2021 18:00:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D93934 --- Comment #25 from Uro=C5=A1 Bizjak --- (In reply to joseph@codesourcery.com from comment #24) > This is a fundamentally different test, because it involves (in the=20 > abstract machine) lvalue-to-rvalue conversion of a sNaN representation.= =20=20 > That means that, unlike the present bug, and the two others I referenced,= =20 > (a) it's only valid with -fsignaling-nans, (b) it's at most a=20 > quality-of-implementation issue because of the rule that assignment to th= e=20 > same format may be a convertFormat operation rather a copy operation, and= =20 > (c) the ABI means the exception can't be avoided when an sNaN is returned= .=20=20 > Effectively, this test is bug 56831, whereas the present bug is more like= =20 > bug 58416 and bug 71460. I would like to point out (in the context of trapping behavior of x87) that= I don't think we should disable FP conditional moves with the patch in Comment #18 to fix the presented corner case, as this will effect the runtime performance of the vast majority of applications that don't care about trap= s. Looking at the above referred bugs, it is IMO time to throw in the towel and declare x87 math as kind-of-broken w.r.t trapping. The compiler will genera= te code that speculatively loads values at various places (as shown by the testcase in Comment #20), not only at the FCMOV site. I'm not a language lawyer, but IMO access to a non-volatile object is not forbidden *if the value is not used*. Unfortunately, some accesses have secondary effects that are not considered by the compiler, and the trapping behavior of FLDS/FLDL is certainly one of them.=