This is the mail archive of the
mailing list for the GCC project.
Detecting superfluous "else"
- From: "U.Mutlu" <um at mutluit dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 19 Jul 2018 10:49:54 +0200
- Subject: Detecting superfluous "else"
it makes me 'crazy' when I see such if-else constructs:
(Of course in this case one better would use the shorthand "return x ? 7 :
4;", but that's not the issue here)
The 'else' is obviously superfluous/redundant, ie. unneeded at all:
Is it possible to warn about such unneccessary occurances of "else"?
If not, then I suggest to add a new warning code -Wsuperfluous-else or
-Wredundant-else or so.