From: David Malcolm <dmalcolm@redhat.com>
To: Tim Lange <mail@tim-lange.me>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v2] analyzer: warn on the use of floating-points operands in the size argument [PR106181]
Date: Thu, 18 Aug 2022 13:21:52 +0100 [thread overview]
Message-ID: <e2384fe9c4a2068d5124986cbaf382e142abc5b5.camel@redhat.com> (raw)
In-Reply-To: <20220818094414.19488-1-mail@tim-lange.me>
On Thu, 2022-08-18 at 11:44 +0200, Tim Lange wrote:
> Hi,
>
> this is the revised version of my patch. I had trouble to get your
> point regarding the float_visitor:
>
> > If the constant is seen first, then the non-constant won't be
> > favored
> > (though perhaps binary ops get canonicalized so that constants are
> > on
> > the RHS?).
>
> Only the assignment of m_result in visit_constant_svalue is guarded
> by
> !m_result, while the other two are not. So, there are two
> possibilities:
> 1. A constant is seen first and then assigned to m_result.
> 1.1. A non-constant float operand is seen later and
> overwrites m_result.
> 1.2. There's no non-constant float operand, thus the
> constant is the actual floating-point operand
> and
> is kept inside m_result.
> 2. A non-constant is seen first, then m_result might be
> overwritten with another non-constant later but never
> with a constant.
> Do I have a flaw in my thinking? (But they do seem to get
> canonicalized,
> so that shouldn't matter)
I think I was confused here, and that you're right. Sorry about that.
>
> > How about:
> > -Wanalyzer-imprecise-float-arithmetic
> > -Wanalyzer-imprecise-fp-arithmetic
> > instead? (ideas welcome)
>
> I've chosen the second. I mostly tried to avoid float because it is
> also
> a reserved keyword in many languages and I wanted to avoid confusion
> (might be overthinking that).
Fair enough.
>
> - Tim
>
> This patch fixes the ICE reported in PR106181 and adds a new warning
> to
> the analyzer complaining about the use of floating-point operands.
>
> Regrtested on Linux x86_64.
Thanks; the patch looks good for trunk.
Dave
prev parent reply other threads:[~2022-08-18 12:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 12:35 [PATCH] analyzer: warn on the use of floating points " Tim Lange
2022-08-15 18:16 ` David Malcolm
2022-08-18 9:44 ` [PATCH v2] analyzer: warn on the use of floating-points operands " Tim Lange
2022-08-18 12:21 ` David Malcolm [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=e2384fe9c4a2068d5124986cbaf382e142abc5b5.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mail@tim-lange.me \
/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).