Article View: gnu.gcc.bug
Article #981Empty-else-body warning considered harmful
From: Josh Marantz
Date: Fri, 21 Aug 1992 19:56
Date: Fri, 21 Aug 1992 19:56
38 lines
1728 bytes
1728 bytes
I frequently compile code that has if statements with empty else
clauses, as the result of macros. I also like to compile with maximum
warning level in gcc. Now (2.2.2) I get warnings for this practice
which used to (1.39) pass thru gcc without warning. Can anything be
done to get rid of this warning without losing all the others?
The warning isn't mentioned in the man page, although it goes away
when I don't use -W (I usually use -Wall). In addition, since it's a
2-line warning, it's hard to clean up the output with a "grep -v"
filter. I wrote a filter in C that does the trick, but it's a real
pain to have to deal with this.
Does anyone else see a lot of value in this warning?
% cat gccwarn.c
int a(x)
int x;
{
if (x)
x = 7;
else;
return (x);
} /* int a */
% gcc-2.2.2 -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/specs
gcc version 2.2.2
% gcc-2.2.2 -W -c gccwarn.c
gccwarn.c: In function `a':
gccwarn.c:7: warning: empty body in an else-statement
% gcc -v
gcc version 1.39
% gcc -W -c gccwarn.c
%
----------------
Joshua Marantz You make my life and times
Viewlogic Systems, a book of bluesy Saturdays
josh@viewlogic.com And I have to choose...
Technical Details
Message-ID:
<9208211956.AA15436@elvis>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!viewlogic.COM!joshShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!viewlogic.COM!josh From: josh@viewlogic.COM (Josh Marantz) Subject: Empty-else-body warning considered harmful Message-ID: <9208211956.AA15436@elvis> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 21 Aug 1992 19:56:17 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 39