Why is this an issue?
This rule is a strict implementation of a MISRA (Motor Industry Software Reliability Association) rule. MISRA defines best practices for developing
safety-critical software. You can learn more about this rule in the MISRA documents referenced below.
If you are not concerned with MISRA compliance or with safety-critical software, you might consider using rule {rule:cpp:S3135} instead ; it
targets the same kind of issue for general-purpose software.
Resources
- MISRA C 2004, 12.3 - The sizeof operator shall not be used on expressions that contain side effects.
- MISRA C++ 2008, 5-3-4 - Evaluation of the operand to the sizeof operator shall not contain side effects.
- MISRA C 2012, 13.6 - The operand of the sizeof operator shall not contain any expression which has potential side effects