public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "segher at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/108432] Analyzer fails to detect out-of-bounds issues within loops
Date: Mon, 23 Jan 2023 18:46:20 +0000	[thread overview]
Message-ID: <bug-108432-4-gI9522syGh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108432-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #2)
> Unfortunately, some analyzer warnings work better with optimization
> *disabled*.  -fanalyzer runs much later than most other static analyzers.

Understood.  But some work better with it enabled, right?

> For example, -Wanalyzer-deref-before-check doesn't work well with
> optimization, as the dereference means that that optimized can remove the
> checks before the analyzer "sees" them.

Yes.

> I think there's a natural tension between optimization and detecting
> undefined behavior, in that -fanalyzer wants to report on possible undefined
> behavior, whereas optimization wants to take advantage of undefined behavior.

"Take advantage of"...  A program that contains UB is erroneous, has no
defined semantics *at all*, so what the compiler is really doing is assuming
the program is a correct program, and generating more optimal target code
based on that not unreasonable assumption.

This sounds a bit better, right?  It still is true that the compiler cannot
detect all UB during compilation (it needs to know the program's input as
well for that, and even then it isn't realistic).  Is it even possible to
detect *all* UB at runtime?

  parent reply	other threads:[~2023-01-23 18:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 15:27 [Bug analyzer/108432] New: " dmalcolm at gcc dot gnu.org
2023-01-23 12:54 ` [Bug analyzer/108432] " segher at gcc dot gnu.org
2023-01-23 16:34 ` dmalcolm at gcc dot gnu.org
2023-01-23 18:46 ` segher at gcc dot gnu.org [this message]
2023-01-26 14:47 ` [Bug analyzer/108432] RFE: analyzer could " dmalcolm at gcc dot gnu.org
2023-01-27 22:12 ` dmalcolm at gcc dot gnu.org
2023-02-01 14:01 ` dmalcolm at gcc dot gnu.org

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-108432-4-gI9522syGh@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).