Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V2554. MISRA. Expression containing...
menu mobile close menu
Additional information
toggle menu Contents

V2554. MISRA. Expression containing increment (++) or decrement (--) should not have other side effects.

Sep 02 2019

This diagnostic rule is based on the software development guidelines developed by MISRA (Motor Industry Software Reliability Association).

Using a decrement (--) or increment (++) operation along with other operators in one expression is not recommended. Using them in an expression that has other side effects makes the code less readable and may result in undefined behavior. A safer practice is to isolate the decrement/increment operators in separate expressions.

Example of non-compliant code:

i = ++i + i--;

This code attempts to modify one variable at one sequence point, which results in undefined behavior.

This diagnostic is classified as:

  • MISRA-C-2012-13.3
  • MISRA-C-2023-13.3
  • MISRA-CPP-2008-5.2.10