public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Andrew Haley <aph@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Question about -Wstrict-overflow=2
Date: Mon, 8 Mar 2021 10:43:00 -0600	[thread overview]
Message-ID: <20210308164300.GE29191@gate.crashing.org> (raw)
In-Reply-To: <2f5d584d-8bdb-6e0f-a50d-bd563aff1bf1@redhat.com>

On Sun, Mar 07, 2021 at 02:56:27PM +0000, Andrew Haley via Gcc-help wrote:
> On 3/7/21 2:04 PM, Alexander Motzkau via Gcc-help wrote:
> > Andrew Haley wrote:
> >> Re upgrading: over time, GCC gets better and better at diagnosing and
> >> providing information. This inevitably means that programmers using
> >> -Werror with high levels of warnings have to change their programs
> >> when a new GCC is used.
> >
> > I understand and I welcome better analysis and optimization
> > techniques.  And I changed several parts due to new warnings. But in
> > this case I don't see any possibility that wouldn't make the code
> > worse except deactivating the warning. Which is sad and normally
> > beside the point of a warning.
> 
> Not all warnings indicate things that should be changed. We expect
> higher levels of warnings to cause false positives, many of which
> can't be avoided, which is why such warnings are not included in
> -Wall.

Yes.  If GCC would know something it warns about is an error, it should
report it as an error.  But it doesn't know.

Some warnings are for things that GCC knows (or its developers know,
really) are often wrong.  Other warnings are for things that aren't so
often wrong, but have a high impact.  And some are for problems that are
hard to find.

-Werror ignores all of this, and makes every warning an error.  That can
be handy for people who know they will ignore all warnings otherwise,
and it is not a huge deal for warnings that are part of -Wall (because
one of the conditions for being included there is that the problem is
easy to avoid, with a trivial code change).  But -Werror is only for
people who think life is too boring and they need some extra challenges,
otherwise.

There is no reason to avoid all warnings.  It is easy to avoid all -Wall
warnings, or even -Wall -Wextra (although if you never used that before
it will find a *lot* of questionable constructs in your code), but most
other warnings are not in either of those two categories precisely
because they are *not* easy to avoid.


Segher

  reply	other threads:[~2021-03-08 16:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-06 10:37 Alexander Motzkau
2021-03-06 11:23 ` Andrew Haley
2021-03-06 12:03   ` Alexander Motzkau
2021-03-07 11:37     ` Andrew Haley
2021-03-07 14:04       ` Alexander Motzkau
2021-03-07 14:56         ` Andrew Haley
2021-03-08 16:43           ` Segher Boessenkool [this message]
2021-03-07 15:31         ` Ian Lance Taylor
2021-03-08 21:05         ` Martin Sebor
2021-03-08 21:57           ` Alexander Motzkau
2021-03-09  9:09           ` Andrew Haley

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=20210308164300.GE29191@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=aph@redhat.com \
    --cc=gcc-help@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).