Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A7-2-1 Still relevant in C++14?
#2
(29-01-2025, 10:03 AM)cgpzs Wrote: Rule A7-2-1 seems copied verbatim from the MISRA C++ 2008 rules. However, there's a key difference: C++14 has scoped enums. There, it is not unspecified (nor undefined) to cast an integer to the enum type when it is not any of the enumerators, since the valid range for the enum is the range of the underlying type. 

Based on that, what would be the rationale for keeping A7-2-1 in the AUTOSAR C++14 rules?

Whilst you are right that when you have a base-type the behaviour is well defined, A7-2-1 also applies when there is no base-type.

Addition, the second paragraph of the rationale applies to all enums, even those that have a base-type.

For a more modern interpretation see MISRA C++:2023.
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread
A7-2-1 Still relevant in C++14? - by cgpzs - 29-01-2025, 10:03 AM
RE: A7-2-1 Still relevant in C++14? - by misra cpp - 4 hours ago

Forum Jump:


Users browsing this thread: 1 Guest(s)