HP Code Advisor C.02.25 User Guide (5900-1864, August 2012)

8 Categories of diagnostics with examples
Cadvise detects a wide range of coding errors and potential problems such as memory leaks, used
after free, double free, array/buffer out of bounds access, illegal pointer access, un-initialized
variables, unused variables, format string checks, suspicious conversion and casts, out of range
operations, and C++ coding style warnings.
8.1 Categories of diagnostics table
Following are some examples of the various checks done by the HP Code Advisor:
Enables all the warnings about potentially questionable constructs in the compiler.+w
Enables all the compile time checks.+wall
Provides compile-time diagnostics which detect potential errors in the source code.“+wlint” (page 45)
Enables warnings that help detection of potential problems in converting 32-bit
applications to 64-bit.
“+w64bit (page 51)
Detects code fragments which are endian dependent.“+wendian (page 51)
Enables compile time diagnostic messages for potential security vulnerabilities.“+wsecurity[=1|2|3|4]” (page 52)
Detects multi-threaded programming issues.“+wlock” (page 53)
Generates performance advisory diagnostics.“+wperfadvice[=1|2|3|4]
(page 54)
+w
This option enables all the warnings about potentially questionable constructs in the compiler.
This includes the +wlint and +w64bit warnings and many others. The number of warnings
generated by this option may be up to 5-10 times more than those generated by +wlint.
This option enables all the warnings about potentially questionable constructs in the compiler.
This includes the +wlint and +w64bit warnings and many others. The number of warnings
generated by this option may be up to 5-10 times more than those generated by +wlint.
Following are some examples of warnings enabled by the +w option:
- Variable is declared but never referenced
- Comparison of unsigned integer with signed integer
- Padding size of structure to alignment boundary
- Argument is incompatible with corresponding format string conversion
+wall
The +wall option enables all the compile time checks. The +wall option includes security
checks and requires cross-module analysis. Hence, you must specify the location of the program
database using the -pdb option, whenever you use +wall.
8.2 Detecting generic programming errors
The compile time diagnostic messages generated by the +wlint option can be very useful in
detecting potential problems in the source code. The number of warnings generated by this option
may be up to 5-10 times more than those generated by default by the compiler. For example, the
following warnings are enabled by this option:
- Argument is incompatible with formal parameter
- Function declared implicitly
- Function is re-declared after being called
8.1 Categories of diagnostics table 45