This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: if() and trailing ;
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'Andreas Schwab'" <schwab at suse dot de>, "'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: Thu, 3 Aug 2006 10:29:22 +0100
- Subject: RE: if() and trailing ;
On 01 August 2006 16:00, Andreas Schwab wrote:
> 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
> any sense.
>
How about
if (condition)
assert (other_dependent_condition);
compiled under NDEBUG?
cheers,
DaveK
--
Can't think of a witty .sigline today....