HP Code Advisor
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
Enables warnings that help detection of potential problems in converting 32-bit
applications to 64-bit.
+w64bit
Detects code fragments which are endian dependent.+wendian
Enables compile time diagnostic messages for potential security vulnerabilities.+wsecurity[=1|2|3|4]
Detects multi-threaded programming issues.+wlock
Generates performance advisory diagnostics.+wperfadvice[=1|2|3|4]
• +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
- Type conversion may truncate value
- Unsigned value cannot be less than zero
8.1 Categories of Diagnostics Table 55