![]() |
|
AUTOSAR C++14 M5-2-10 for unique_ptr in combination with ++ operator - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: AUTOSAR C++:2014 rules (https://forum.misra.org.uk/forumdisplay.php?fid=185) +--- Thread: AUTOSAR C++14 M5-2-10 for unique_ptr in combination with ++ operator (/showthread.php?tid=1769) |
AUTOSAR C++14 M5-2-10 for unique_ptr in combination with ++ operator - kth - 08-05-2026 The AUTOSAR C++14 Guidelines ("AUTOSAR Guidelines for the use of the C++14 language in critical and safety-related systems") contain the MISRA C++:2008 rule 5-2-10 as rule M5-2-2. M5-2-2 was modified to required but - AFAIK - nothing else was changed. Quote:Rule M5-2-10 (required, implementation, automated) There is a similar MISRA C:2012/2023/2025 rule Quote:Rule 13.3 A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator Also some examples are shared: Code: u8a = ++u8b + u8c--; // Non-compliantWhile this makes makes sense for C and C++, there are differences between C and C. What about the following code: Code: #include <cstdint>Shall a AUTOSAR C++14/MISRA C++:2008 checker report a violation for "d->member++" or is that OK? RE: AUTOSAR C++14 M5-2-10 for unique_ptr in combination with ++ operator - misra cpp - 08-05-2026 We think that M5-2-2 is not relevant to this topic. The relevant AUTOSAR rule is M5-2-10. AUTOSAR took the M5-2-10 headline from that in MISRA C++::2008, and whilst that says "... should not be mixed with other operators in an expression", the rationale makes it clear that this only applies to arithmetic operators, so a checker should accept "d->member++;" |