Followup to: <Pine.LNX.4.04.10002231309270.12259-100000@beaker>
By author: Ricky Beam <jfbeam@bluetopia.net>
In newsgroup: linux.dev.kernel
> >
> > if (foo);
> > bar;
>
> Those are perfectly legal constructions. The compiler, while certainly
> magic, isn't a psychic.
>
Legal, yes. It's also useless (if you really meant it, you ought to
write "foo; bar;" which is equivalent.) Therefore, it should be fixed
one way or the other. Unlike a for or while statement with an empty
clause -- which sometimes have legitimate uses -- an if statement with
an empty clause is pretty much useless. The only case I've seen which
makes sense is if you have something like:
if (foo)
; /* Do nothing */
else
bar;
Note that I *highly* recommend having a comment for this case, to
indicate that there really is no mistake. Same with /* fallthrough */
in switch statements.
I actually would recommend using { } instead of ; as well.
-hpa
-- <hpa@transmeta.com> at work, <hpa@zytor.com> in private! "Unix gives you enough rope to shoot yourself in the foot."- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:34 EST