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++


LANG.STRUCT.SE.IOE : Indeterminate Order of Evaluation

Summary

One of the following occurs in a statement-level expression, or between two sequence points.

Properties

Class Name Indeterminate Order of Evaluation
Significance reliability
Mnemonic LANG.STRUCT.SE.IOE
Categories
MisraC2025 MisraC2025:13.2 The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders and shall be independent from thread interleaving
MisraC2023 MisraC2023:13.2 The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders and shall be independent from thread interleaving
Misra2012 Misra2012:13.2 The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders and shall be independent from thread interleaving
Misra2004 Misra2004:12.2 The value of an expression shall be the same under any order of evaluation that the standard permits
AUTOSARC++14 AUTOSARC++14:A5-0-1 The value of an expression shall be the same under any order of evaluation that the standard permits.
MisraC++2008 MisraC++2008:5-0-1 The value of an expression shall be the same under any order of evaluation that the standard permits.
MisraC++2023 MisraC++2023:4.6.1 Operations on a memory location shall be sequenced appropriately
CWE CWE:758 Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
CERT-C CERT-C:EXP10-C Do not depend on the order of evaluation of subexpressions or the order in which side effects take place
JSF++ JSF++:204.1 The value of an expression shall be the same under any order of evaluation that the standard permits.
JPL JPL:18 Make the order of evaluation in compound expressions explicit.
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Indeterminate Order of Evaluation"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

int lang_struct_se_ioe(int x){
    int rv1 = ++x - ++x; /* 'Indeterminate Order of Evaluation' warning issued here
                          * - two unsequenced writes to x
                          * The different orderings have different outcomes:
                          * - if the compiler chooses to perform the first increment
                          *   before the second, (++x - ++x) == -1
                          * - if the compiler chooses to perform the second increment
                          *   before the first, (++x - ++x) == 1
                          */
    int rv2 = ++x + ++x; /* 'Indeterminate Order of Evaluation' warning issued here
                          * - two unsequenced writes to x
                          * Ihe value of (++x + ++x) is the same under
                          * all possible sequencings, but a warning is
                          * issued regardless.
                          */
    int rv3 = (--x > 0) || (++x < 0);      /* ok: || is a sequence point */
    int rv4 = x + 2*x;                     /* ok: no writes to x */
    ++rv4;                                 /* ok: the value read from rv4 contributes to the value written to rv4 */
    return ++rv1 + ++rv2 + ++rv3 + ++rv4;  /* ok: each object is only incremented once */
}

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/.