🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2813

Re: gcc warning: empty body in else-statement

#2813
From: Arthur David Olson
Date: Tue, 09 Jan 1990 01:23
31 lines
1423 bytes
> If I compile with -Wall, I get warnings about else statements with
> empty bodies, e.g.
> 
> 	if (expr)
> 		f();
> 	else	;
> 
> ...These warnings don't seem very useful to me; am I missing something?
> Is there a common error that will be caught by the warning?

The "common" error caught by the code generating the above message is...
	if (expression);
		statement;
...where the extra semicolon at the end of the first line results in
"statement" being executed unconditionally.  The "else" case is designed to
guard against the less-common...
	if (expression);
		statement;
	else; if (expression2)
		statement2;
	else	statement3;

On the system here at least, you can eliminate the warning by having the
macro generate code in the form...
	if (expr)
		f();
	else	{}
-- 
		1972:  Canada has no Saturn V equivalent
		1990:  Canada has no Saturn V equivalent
	Arthur David Olson   ado@alw.nih.gov   ADO is a trademark of Ampex.
Technical Details
Message-ID: <9237@elsie.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!psuvax1!ukma!dftsrv!mimsy!cvl!elsie!ado
References: <9001082242.AA00768@jan.ultra.nyu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!psuvax1!ukma!dftsrv!mimsy!cvl!elsie!ado
From: ado@elsie.UUCP (Arthur David Olson)
Newsgroups: gnu.gcc.bug
Subject: Re: gcc warning: empty body in else-statement
Message-ID: <9237@elsie.UUCP>
Date: 9 Jan 90 01:23:40 GMT
References: <9001082242.AA00768@jan.ultra.nyu.edu>
Distribution: gnu
Organization: NIH-LEC, Bethesda, MD
Lines: 31