This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Please, take '-Wmisleading-indentation' out of -Wall
- From: Antonio Diaz Diaz <antonio at gnu dot org>
- To: gcc at gcc dot gnu dot org
- Cc: Antonio Diaz Diaz <antonio at gnu dot org>
- Date: Thu, 05 May 2016 20:56:36 +0200
- Subject: Re: Please, take '-Wmisleading-indentation' out of -Wall
- Authentication-results: sourceware.org; auth=none
- References: <572A2029 dot 6030106 at gnu dot org> <1462386029 dot 14738 dot 43 dot camel at redhat dot com> <572A4F0A dot 2070304 at gmail dot com>
Manuel López-Ibáñez wrote:
Many useful warnings are outside -Wall/-Wextra because there were bugs
when initially implemented, users complained, they were moved out and
then either the bugs were forgotten or they got fixed but nobody
bothered to move them again within -Wall/-Wextra.
I am sure that you are right, but my point is that
-Wmisleading-indentation is different. For example, I think that macro
expansion should not be considered when evaluating if indentation is
misleading, because the human that could be mislead sees the source
itself, not the preprocessed input.
Take this example http://gcc.gnu.org/ml/gcc-patches/2016-03/msg00261.html
The user sees this:
if (flagA) // GUARD
foo (0); // BODY
#if SOME_CONDITION_THAT_DOES_NOT_HOLD
if (flagB)
#endif
foo (1); // NEXT
not this:
if (flagA) // GUARD
foo (0); // BODY
foo (1); // NEXT
See https://gcc.gnu.org/PR52961
-Wempty-body is already enabled with -Wextra.
Nowadays it is extremely easy to disable a warning that annoys you
At the cost of receiving spurious bug reports about unknown pragmas from
users compiling my projects with older versions of gcc or with non-gcc
compilers, I guess.
(the name is written in the message and you can use #pragmas very
selectively), but still quite hard to discover which warning you need to
enable that could have found a certain bug. It is also much harder to
find regressions in warnings not enabled by -Wall -Wextra because they
are not tested as much.
Maybe add an -Weverything that enables ALL warnings? I would be happy to
test it.
I really commend David for being brave and putting the warning in -Wall.
s/being brave/using users as guinea pigs/ ;-)
The easy way out would have been to say: "I know how to enable it, so
let's hide it so that users do not complain to me about bugs that I
don't suffer". We (myself included) have done this plenty of times in
the past and the result is always the same: bugs don't get fixed,
regressions appear, and users complain about missing warnings that are
actually already implemented.
-Weverything could help in assesing which warnings are ready for
-Wall/-Wextra.
I agree that GCC warnings could be better categorized, but your proposed
categories are not clearly defined. A better classification would look
at the possibilities of false positives, how easy is to silence it,
whether it is "undefined/unspecified at runtime", "undefined/unspecif
under some conditions but not others", "atypical code that is
often/sometimes a bug", "typical code that is often/sometimes a bug",
etc. Of course, this would be a lot of work that no one wants to do ;-)
Perhaps this could be made by improving the definitions of -Wall and
-Wextra in the manual (and perhaps adding new categories, maybe
including -Weverything), and then assigning every new/moved warning to
the corresponding category. Just my 2 cents.
Best regards,
Antonio.