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 tree-optimization/101830] [12 Regression] Incorrect error messages beginning with r12-2591 (backward jump threader)
Date: Tue, 10 Aug 2021 01:30:47 +0000	[thread overview]
Message-ID: <bug-101830-4-XaTQCQMsCe@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101830-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to Bill Schmidt from comment #0)
> (1) linebuf and pos are global variables, and the compiler cannot tell
> whether or not there are problems with array bounds accesses here. Indeed,
> pos is only incremented by a function called "safe_inc_pos" that ensures we
> *don't* ever access beyond the end of linebuf.

Most warnings are heuristic, largely by need, and this is true here as well.
-Werror is a terrible idea.  You can use it during development if you don't
trust the programmers (which might be yourself) will see the messages, but
otherwise it is just a destructive hindrance.  That said...

> (2) The error message is far too certain of itself!  It says that we have
> definitely addressed out of bounds when that is certainly not known to be
> true.

And its language claims it is even more certain that this was linepos+1024,
which you say can never be true?

It is possible there is some other bug in your program, which combined with
aggressive optimisations elsewhere gives the access to that address, but :-/
(Looking at -fdump-tree-all-all dumps should tell).

More likely is the heuristic just gets the wrong result.  This happens so
often that this warning does not belong in -Wall, and not even in -W (since
there is no simple workaround for it at all, not even any reliable
workaround).

And yes, whenever some warning includes any heuristic (i.e. almost all
warnings), the warning message should not say "is wrong".  Diagnostics should
never lie.  Not ever.  This used to be a big strength of GCC's diagnostics.

All such messages should say something like "may be wrong".  This is a much
nicer, more respectful way to talk to the compiler user anyway, even if it
could not be wrong :-)


> This is holding up committing some approved patches, so I appreciate
> anything you can do to sort this out.

Configure with --disable-werror if you want more sanity.  Of course people
will then be angry with you if you commit something that triggers something
bad :-/  Maybe that builds character?

  parent reply	other threads:[~2021-08-10  1:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 15:54 [Bug tree-optimization/101830] New: " wschmidt at gcc dot gnu.org
2021-08-09 15:57 ` [Bug tree-optimization/101830] " wschmidt at gcc dot gnu.org
2021-08-09 17:55 ` pinskia at gcc dot gnu.org
2021-08-09 19:46 ` [Bug tree-optimization/101830] [12 Regression] " wschmidt at gcc dot gnu.org
2021-08-10  1:30 ` segher at gcc dot gnu.org [this message]
2021-08-10 12:33 ` wschmidt at gcc dot gnu.org
2021-08-12 17:35 ` msebor at gcc dot gnu.org
2021-08-12 17:47 ` wschmidt at gcc dot gnu.org
2021-08-12 17:50 ` msebor at gcc dot gnu.org
2021-08-12 18:06 ` wschmidt at gcc dot gnu.org
2021-08-12 18:44 ` wschmidt at gcc dot gnu.org
2021-08-12 19:54 ` wschmidt at gcc dot gnu.org
2021-08-12 20:15 ` msebor at gcc dot gnu.org
2021-08-12 20:39 ` wschmidt at gcc dot gnu.org
2021-08-23 21:00 ` [Bug target/101830] " cvs-commit 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-101830-4-XaTQCQMsCe@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).