This is the mail archive of the
mailing list for the GCC project.
Re: if() and trailing ;
- From: Andreas Schwab <schwab at suse dot de>
- To: Joe Buck <Joe dot Buck at synopsys dot COM>
- Cc: Simon Boulet <simon at nostalgeek dot com>, gcc at gcc dot gnu dot org
- Date: Tue, 01 Aug 2006 17:00:29 +0200
- Subject: Re: if() and trailing ;
- References: <5A1EA79B-D8B0-4076-8E22-7F81BAA5685C@nostalgeek.com> <20060730043255.GA10835@synopsys.com>
Joe Buck <Joe.Buck@synopsys.COM> writes:
> On Sat, Jul 29, 2006 at 07:33:03PM -0400, Simon Boulet wrote:
>> After a couple hours debugging code, I figured our an if() somewhere
>> had a trailing ; like this:
>> if (memcmp(p, COMMUNITY, strlen(COMMUNITY)) != 0);
>> continue; /* failed */
>> The code above will always reach "continue" even when memcmp() == 0.
>> I was surprised to see gcc doesn't report anything, I would expect a
>> "statement has no effect" warning.
> But it is common to have an empty action on a condition. You'll often
> see code like
> if (condition)
> /* nothing */;
Having an empty action on a condition without an else clause does not make
Andreas Schwab, SuSE Labs, firstname.lastname@example.org
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."