MISRA Discussion Forums
4.1.1 Can MISRA C++:2023 be used with C++14 code? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=188)
+---- Forum: 4.4 General principles (https://forum.misra.org.uk/forumdisplay.php?fid=190)
+---- Thread: 4.1.1 Can MISRA C++:2023 be used with C++14 code? (/showthread.php?tid=1760)



4.1.1 Can MISRA C++:2023 be used with C++14 code? - cgpzs - 16-12-2025

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.


RE: 4.1.1 Can MISRA C++:2023 be used with C++14 code? - misra cpp - 19-12-2025

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.