public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-93934-4-kLbIdWoNSd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-93934-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #25 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to joseph@codesourcery.com from comment #24)
> This is a fundamentally different test, because it involves (in the 
> abstract machine) lvalue-to-rvalue conversion of a sNaN representation.  
> That means that, unlike the present bug, and the two others I referenced, 
> (a) it's only valid with -fsignaling-nans, (b) it's at most a 
> quality-of-implementation issue because of the rule that assignment to the 
> same format may be a convertFormat operation rather a copy operation, and 
> (c) the ABI means the exception can't be avoided when an sNaN is returned.  
> Effectively, this test is bug 56831, whereas the present bug is more like 
> 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 traps.
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 generate
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.

      parent reply	other threads:[~2021-10-14 18:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-93934-4@http.gcc.gnu.org/bugzilla/>
2021-10-13 10:20 ` vajdaz at protonmail dot com
2021-10-13 10:58 ` rguenth at gcc dot gnu.org
2021-10-13 12:50 ` ubizjak at gmail dot com
2021-10-13 13:39 ` vajdaz at protonmail dot com
2021-10-13 14:36 ` ubizjak at gmail dot com
2021-10-13 15:11 ` amonakov at gcc dot gnu.org
2021-10-13 17:54 ` vajdaz at protonmail dot com
2021-10-13 21:47 ` joseph at codesourcery dot com
2021-10-14  7:21 ` rguenth at gcc dot gnu.org
2021-10-14  8:42 ` ubizjak at gmail dot com
2021-10-14 10:05 ` vajdaz at protonmail dot com
2021-10-14 10:18 ` ubizjak at gmail dot com
2021-10-14 10:34 ` ubizjak at gmail dot com
2021-10-14 10:42 ` rguenther at suse dot de
2021-10-14 14:15 ` vajdaz at protonmail dot com
2021-10-14 16:26 ` joseph at codesourcery dot com
2021-10-14 18:00 ` ubizjak at gmail dot com [this message]

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