[cfe-dev] Running scan-build on multiple source files

Robert Henry rrh at newrelic.com
Thu May 30 05:53:20 PDT 2013


I have two source files each of which is analyzed independently
without error by scan-build.  However, the combination of the 2 files
should trigger a complaint from scan-build, assuming scan-build has
inter-procedural analysis spanning the two compilation units.
However, scan-build is silent.  Is this beyond the capabilities of
scan-build, or am I invoking the tool incorrectly?
(If I concatenate the source for the two files into a single file,
then scan-build finds the expected error.)

Here's how I invoke scan-build:
  scan-build gcc a.c b.c

where a.c contains:

#include <stdio.h>
extern int b (int i);
int main (int argc, const char **argv)
{
  int i;
  for (i = 0; i < 10; i++) {
    printf ("i=%d ratio=%d\n", i, i/ b(i)); // Note zero divide here
  }
  return 0;
}

and b.c contains the identity function:
 int b (int i) { return i; }


--
Robert Henry, New Relic



More information about the cfe-dev mailing list