Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
It 8.12 intended to be so strict?
#1
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 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.
Reply


Messages In This Thread
It 8.12 intended to be so strict? - by Loïc - 25-06-2026, 10:05 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)