lclint-interest message 90

From Thu Jul 18 15:44:31 1996
Date: Thu, 18 Jul 96 15:29:12 -0400
From: (David Evans)
In-Reply-To: Mike Ellis's message of Thu, 18 Jul 1996 16:11:41 +0100 <>
Subject: Initialising arrays in loops


The problem here is that lclint can't tell that the loop body must
always execute, and hence, if array[0] is defined after the loop.

One way to fix this, is to use stylized comments to mark that the loop
always executes:

  for (count = 0; count <= 3; count++)
      array[count] = count;

(You could also set +loopexec at the command line if you want lclint to
assume all loop bodies execute at least once, however, this could lead
to relevant errors being undetected.)

For loops with constant bounds like this one, lclint should probably be
able to figure out without the hint that the loop body always executes,
but currently there it doesn't do this.

--- Dave

Previous Message Next Message Archive Summary LCLint Home Page David Evans
University of Virginia, Computer Science