Go to main content
Oracle® Developer Studio 12.6: Code Analyzer User's Guide

Exit Print View

Updated: June 2017

Collecting Static Error Data

To collect static error data on your C or C++ program, compile the program using Oracle Solaris Studio 12.3 or 12.4, or Oracle Developer Studio 12.5 or 12.6 C or C++ compiler with the –xprevise=yes option. Previously, you used the –xanalyze=code option, but this option is EOL and it is recommended to use the –xprevise=yes option instead. The –xprevise=yes option is not available in the compilers in previous releases of Oracle Developer Studio. When you use this option, the compiler automatically extracts static errors and writes the data to the static subdirectory in the binary-name.analyze directory.

If you compile your program with the –xprevise option and link it in a separate step, you must also include the –xprevise option in the link step.

On Linux, you must specify the –xannotate option with –xprevise=yes in order to collect static error data. For example:

% cc -xprevise=yes -xannotate -g t.c

Note that the compilers cannot detect all of the static errors in your code.

  • Some errors depend on data that is available only at runtime. For example, given the following code, the compiler would not detect an ABW (beyond array bounds write) error because it could not detect that the value of ix, read from a file, lies outside the range [0,9]:

    void f(int fd, int array[10])
      int ix;
      read(fd, &ix, sizeof(ix));
      array[ix] = 0;
  • Some errors are ambiguous,and also might not be actual errors. The compiler does not report these errors.

  • Some complex errors are not detected by the compilers in this release.

After collecting static error data, you can start Code Analyzer's GUI or the command-line tool (codean) to analyze and display the data or recompile the program so that you can collect dynamic memory access or code coverage data.