This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Should -Wmaybe-uninitialized be included in -Wall?
- From: Michael Matz <matz at suse dot de>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Ryan Hill <dirtyepic at gentoo dot org>, gcc at gcc dot gnu dot org
- Date: Thu, 11 Jul 2013 18:18:40 +0200 (CEST)
- Subject: Re: Should -Wmaybe-uninitialized be included in -Wall?
- References: <87ehb8rljz dot fsf at br87z6lw dot de dot ibm dot com> <51DBFC32 dot 8050401 at redhat dot com> <87siznrg4y dot fsf at br87z6lw dot de dot ibm dot com> <51DC872C dot 7030303 at redhat dot com> <CAAiZkiBNbjsgSfmzmiiLqcpjS2he0JwRq_+4Gp8TzgE1WYkS7A at mail dot gmail dot com> <20130710234218 dot 16d24de8 at caribou dot gateway dot 2wire dot net> <CAAiZkiBG28FeeHwrof=YxgQXbtVB_Dmg_gTqtS2CaaeS2Sp=ew at mail dot gmail dot com>
Hi,
On Thu, 11 Jul 2013, Gabriel Dos Reis wrote:
> > Arg, no. -Werror is very useful for development and I'm sure that
> > code quality increases because of it, but it should never be enabled
> > by default for releases. I think about 80% of the bugs we've had
> > filed so far for packages failing to build against 4.8 are due to
> > -Werror.
>
> The fact that you have 80% failing to build is not in itself an argument
> for not including -Werror in release mode. The real issue is whether
> those warnings uncovered any real bugs. If they don't, then either we
> are emitting too many false positives, or those packages should have
> turned off the offending diagnostics.
Not quite. The problem is that the compiler is used for two completely
different things:
1) by developers to develop their code, a development too. They will use
a certain version of GCC, hence enabling -Wall -Werror is indeed
good practice; even with the expectation that the developer will
eventually change the used GCC version implying different errors; this
will merely result in the source base to be improved by that developer
to also conform to the new warnings (and hopefully not in a way that
it warns with the old compiler again)
2) by users of software (which includes distributors as one of the largest
consumers of random source codes) as sort of install tool. This
will most of the time _not_ be the version of the compiler that the
developer used when the software was released. As we already
determined adding -Werror effectively makes the software require a very
specific GCC version, but only because of warnings.
Individual consumers of software usually are not inherently interested
in such warnings, and distributors have different ways of enforcing
policies related to source code quality (e.g. by parsing build logs).
Adding -Werror by developers for their released software is hence
neither required, nor even advised, it'll merely make life harder for
consumers.
Then, of course, there's a mixture between consumers and developers, who
might indeed be interested in warnings with the intention of helping the
sources developers. Well, as they are developers themself, they should
know a way to add -Werror themself.
So, no, -Werror for delivered stuff is no good idea.
> > Also, several distros patch gcc to enable additional warnings by
> > default (eg. Debian, Ubuntu, and Gentoo enable -Wformat=security) that
> > upstream may not see or be interested in. It's a big enough headache
> > that we had to ban use of -Werror from our tree (instead we flag
> > important warnings and output them at the end of the build).
>
> Well, the issue isn't as clear cut as you make it sound. Some distros
> build service
> monitor compiler outputs for some of these warnings and abort builds
> even if the package does not supply -Werror.
Yes, one reason why -Werror for application delivery is unnecessary.
Ciao,
Michael.