![]() |
|
It 8.12 intended to be so strict? - 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.8 Declarations and defnitions (https://forum.misra.org.uk/forumdisplay.php?fid=163) +---- Thread: It 8.12 intended to be so strict? (/showthread.php?tid=1774) |
It 8.12 intended to be so strict? - Loïc - 25-06-2026 Hello, It is clear by looking at the title of rule 8.12 Quote:Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique That the following code is non-compliant: Code: // Non-compliant, yellow has an implixitly defined value that it shares with lastThis is a relatively common pattern, and the alternatives seem worse. It is the intent of this rule to prevent this pattern, or is it just a result of the wording? By the way, this code is compliant with the C++ version of this rule in MISRA C++:2023. RE: It 8.12 intended to be so strict? - misra-c - 08-10-2026 The MISRA C rule 8.12 is an example of a simple deterministic rule, that traps circumstances that one might wish to permit. The related MISRA C++:2023 rule 11.6.3 has an exception which appears to resolve the issue highlighted. The MISRA C WG will consider adding the exception to a future update of MISRA C |