MISRA C++:2008 Rule 5-0-1
The value of an expression shall be the same under any order of evaluation that the standard permits
Description
Rule Definition
The value of an expression shall be the same under any order of evaluation that the standard permits.1
Rationale
If an expression results in different values depending on the order of evaluation, its value becomes implementation-defined.
Polyspace Implementation
Polyspace® raises a violation if an expression satisfies any of these conditions:
- The same variable is modified more than once in the expression or it is both read and written. 
- The expression allows more than one order of evaluation. 
- The expression contains a single - volatileobject that occurs multiple times.
- The expression contains more than one - volatileobject.
Because volatile objects can change their value at
                anytime, an expression containing multiple volatile variables or
                multiple instances of the same volatile variable might have
                different results depending on the order of evaluation. 
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group: Expressions | 
| Category: Required | 
Version History
Introduced in R2013b1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
- MISRA C:2004 
- MISRA C:2012 
- MISRA C:2023 
- MISRA C++:2008 
- MISRA C++:2023 
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.