25-06-2026, 10:05 PM
Hello,
It is clear by looking at the title of rule 8.12
That the following code is non-compliant:
This 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.
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 last
enum colour { red, blue, green, yellow, last = yellow };This 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.

