This is motivated by a question that I made previously (on the same topic):
Do BLAS and LAPACK libraries comply with MISRA standard?
Now I have a much more important question: is libstdc++ (which is the implementation of the standard library by gcc) MISRA C++:2008 compliant? I assume the answer is yes... as long as you compile your code with gcc
and the -std=c++03
flag.
What happens if I compile the code with the standard from 2011 (i.e. -std=c++11
)? Is that MISRA C++:2008 compliant? Do I have to prove that the libstdc++ is MISRA compliant? I can write deviations for a couple of rules (for example, I want to use std::array
instead of C-style arrays), but writing them for the whole MISRA standard looks like a terryfying task.
I would appreciate any insight into this topic.
No, it is not MISRA-C++ compliant. Neither is glibc. But then there's no requirement from the standard that the library must be written in a certain language either. Standard compliance for the standard library itself is a rather muddy topic, with or without MISRA.
I very much doubt that MISRA-C++ is a priority for these libraries. The library (and gcc) maintainers are mostly from the Linux/Desktop ("hosted system") side of things, where MISRA compliance isn't required.
If you need a MISRA compliant standard library, you'll have to look at the various commercial embedded systems compilers.
What happens if I compile the code with the standard from 2011? Is that MISRA C++:2008 compliant?
No it is not compliant. MISRA-C++ requires explicitly that you use C++03, so it will be very hard to justify a deviation here.
Do I have to prove that the libstdc++ is MISRA compliant?
There is no way to prove it, since it is not.