This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Comments for empty for-loop parts (was Re: xserver: Branch 'master' - 6 commits)
- From: Bernardo Innocenti <bernie at codewiz dot org>
- To: Ian Romanick <idr at us dot ibm dot com>
- Cc: Discuss issues related to the xorg tree <xorg at lists dot freedesktop dot org>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Mon, 04 Jun 2007 23:57:38 -0400
- Subject: Re: Comments for empty for-loop parts (was Re: xserver: Branch 'master' - 6 commits)
- References: <20070524214549.9C9F410096@kemper.freedesktop.org> <466471C0.3000702@us.ibm.com>
Ian Romanick wrote:
Over the years, I have encountered *may* bugs like this. One way to
help combat them is to have a policy that empty loop parts are
documented with a comment of /* empty */. It makes it explicit to
people reading the code that the missing parts are intentionally
missing. It also helps prevent deletion of the "stray" semicolon of an
empty loop body.
Some compilers have an option to warn on empty loop
and "if" bodies. To shut it up, you can replace the
";" with an empty block instead: "{ }", which also
shows the intention more clearly to humans.
Surprisingly, gcc does not seem to support this
warning as of 4.1.
--
// Bernardo Innocenti
\X/ http://www.codewiz.org/