if() and trailing ;
Dale Johannesen
dalej@apple.com
Sun Jul 30 02:19:00 GMT 2006
On Jul 29, 2006, at 4:33 PM, Simon Boulet wrote:
> Hi,
>
> 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.
>
> Using gcc version 3.3.5 (Debian 1:3.3.5-13)
-Wextra enables this warning, as documented. Not 100% sure it was
there in 3.3.
If not you might want a more recent compiler.
More information about the Gcc
mailing list