JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Binaries


DIAG.UNEX.COMP : Unexercised Computation

Summary

Some of the code in a function is not exercised by the CodeSonar analysis; the most serious statement in the unexercised set is a computation (such as addition) on data.

Warnings of this and other Unexercised Code warning classes typically arise when the setting of configuration parameter SEARCH_BOUND is not high enough to permit all code to be exercised. Increase this setting to reduce or eliminate these warnings. Increase this setting to reduce these warnings, at the cost of increased analysis time. In most real programs, a search bound high enough to eliminate all Unexercised Code warnings will cause the analysis to take an impractically long time.

Note that these classes are concerned with code coverage rather than path coverage: in some cases it is entirely possible to cover all code in a procedure with a strict subset of the possible paths through that procedure.

For more information, see Unexercised Call: Note: Unexercised Code Warning Classes.

Properties

Class Name Unexercised Computation
Significance diagnostic
Mnemonic DIAG.UNEX.COMP
Categories
MisraC2025 MisraC2025:2.1 A project shall not contain unreachable code
MisraC2023 MisraC2023:2.1 A project shall not contain unreachable code
Misra2012 Misra2012:2.1 A project shall not contain unreachable code
Misra2004 Misra2004:14.1 There shall be no unreachable code
AUTOSARC++14 AUTOSARC++14:M0-1-1 A project shall not contain unreachable code.
  AUTOSARC++14:M0-1-2 A project shall not contain infeasible paths.
MisraC++2008 MisraC++2008:0-1-1 A project shall not contain unreachable code.
  MisraC++2008:0-1-2 A project shall not contain infeasible paths.
MisraC++2023 MisraC++2023:0.0.1 A function shall not contain unreachable statements
CWE CWE:561 Dead Code
CERT-C CERT-C:MSC07-C Detect and remove dead code
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
JSF++ JSF++:186 There shall be no unreachable code.
DISA-3r10 DISA-3r10:V-6149 The designer will ensure the application does not contain source code that is never invoked during operation, except for software components and libraries from approved third-party products.
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default. To enable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Unexercised Computation"

This class is for analysis diagnostics, rather than for warning about issues in your code. As such, it is generally not enabled by CodeSonar presets. In particular, it is not enabled by the all_warningclasses preset.

Example

For the sake of compact illustration, we lower the setting of SEARCH_BOUND by adding the following configuration file rule.

SEARCH_BOUND=3

With SEARCH_BOUND=3, CodeSonar will only explore three paths in procedure unex_comp(). However, there are four paths through the procedure: if only three paths are explored, one of the switch cases will not be exercised. The most serious statement type in each switch case is a computation, so an Unexercised Computation warning will be issued at one of those statements. We cannot predict exactly which one from source code alone: it will depend on various phenomena in the CodeSonar build and analysis.

int g(void);
        
void unex_comp(int j)
{
    int i = g();
    switch( j )
    {
    case __LINE__: j++; if (i) i=4; return; break;  /* 'Unexercised Computation' warning issued either here... */
    case __LINE__: j++; if (i) i=4; return; break;  /* ...or here... */
    case __LINE__: j++; if (i) i=4; return; break;  /* ...or here... */
    default: j++; if (i) i=4; return; break;        /* ...or here. */
    }
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.codesecure.com/.