Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
4.1.1 Can MISRA C++:2023 be used with C++14 code?
#1
Rule 4.1.1 says code must comply with ISO C++ 17. Does this mean the code "must" be compiled with the -std=c++17 flag? Is there otherwise a good way to use MISRA C++:2023 on C++14 code (-std=c++14)? The motivation is to drop the AUTOSAR C++14 guidelines (which have been deprecated) and move to the more modern guidelines, while still keeping the standard used for compilation.
Reply
#2
In effect, yes, code should be compiled as C++17.

If you want to continue to use C++14, then 4.1.1 must be deviated.
The justification for the deviation needs to consider:
    - there may be rules that require the use of C++17 features, that obviously won't compile under C++14
    - there are rules we removed because the behaviour they are trying to prevent is no longer possible in C++17

The first category is easy to spot, the code won't compile.

The second is more challenging, e.g. C++17 changed sequence point analysis so code that had UB in C++14 is well defined in C++17. If we were writing the rules for C++14 we'd have added a rule to prevent the UB.

You may have to do a gap analysis between AUTOSAR C++14 and MISRA C++:2023, to identify where there are significant issues that are not covered.
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)