![]() |
|
Rule 13.3 incr/decr op in initialization - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.13 Side effects (https://forum.misra.org.uk/forumdisplay.php?fid=168) +---- Thread: Rule 13.3 incr/decr op in initialization (/showthread.php?tid=1749) |
Rule 13.3 incr/decr op in initialization - delirium5223 - 04-09-2025 Based on the example in MISRA 2023 C this is non-compliant: Code: int u8a=0; // impliedbut what about in initialization? According to PCLP tool it's acceptable: Code: int u8a = u8b++;My view is that de/increment shouldn't be mixed with anything and it should be alone in one line to avoid any chance of confusion. Please clarify. RE: Rule 13.3 incr/decr op in initialization - misra-c - 20-11-2025 The examples for Rule 13.3 state: Code: The expression:The glossary also clarifies that assignment includes Using an expression to initialize all or part of an object. From this, the intent of Rule 13.3 (Advisory) is that use of ++ in an initialization is non-compliant. |