Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Josh Marantz
Fri, 21 Aug 1992 19:56
Empty-else-body warning considered harmful
Author: 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...
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads