This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Comments for empty for-loop parts (was Re: xserver: Branch 'master' - 6 commits)


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]