简体   繁体   English

libstdc ++是否符合MISRA C ++?

[英]Does libstdc++ comply with MISRA C++?

This is motivated by a question that I made previously (on the same topic): 这是由我之前(在同一主题上)提出的一个问题引起的:

Do BLAS and LAPACK libraries comply with MISRA standard? BLAS和LAPACK库是否符合MISRA标准?

Now I have a much more important question: is libstdc++ (which is the implementation of the standard library by gcc) MISRA C++:2008 compliant? 现在,我有一个更加重要的问题: libstdc ++ (由gcc实现的标准库)是否符合MISRA C ++:2008? I assume the answer is yes ... as long as you compile your code with gcc and the -std=c++03 flag. 我认为答案是肯定的 ……只要您使用gcc-std=c++03标志编译代码即可。

What happens if I compile the code with the standard from 2011 (ie -std=c++11 )? 如果我使用2011年-std=c++11的标准(即-std=c++11 )编译代码,会发生什么情况? Is that MISRA C++:2008 compliant? 该MISRA C ++:2008是否兼容? Do I have to prove that the libstdc++ is MISRA compliant? 我是否必须证明libstdc ++符合MISRA? 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. 我可以为一些规则写偏差(例如,我想使用std::array而不是C样式的数组),但是为整个MISRA标准编写它们似乎是一项艰巨的任务。

I would appreciate any insight into this topic. 如果您对此主题有任何见解,我将不胜感激。

No, it is not MISRA-C++ compliant. 不,它不符合MISRA-C ++的要求。 Neither is glibc. 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. 无论是否具有MISRA,标准库本身的标准合规性都是一个相当混乱的话题。

I very much doubt that MISRA-C++ is a priority for these libraries. 我非常怀疑MISRA-C ++是这些库的优先级。 The library (and gcc) maintainers are mostly from the Linux/Desktop ("hosted system") side of things, where MISRA compliance isn't required. 库(和gcc)的维护者主要来自Linux / Desktop(“托管系统”)方面,不需要MISRA合规性。

If you need a MISRA compliant standard library, you'll have to look at the various commercial embedded systems compilers. 如果需要符合MISRA的标准库,则必须查看各种商业嵌入式系统编译器。

What happens if I compile the code with the standard from 2011? 如果我使用2011年以来的标准编译代码会怎样? Is that MISRA C++:2008 compliant? 该MISRA C ++:2008是否兼容?

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. MISRA-C ++明确要求您使用C ++ 03,因此在此处很难证明存在偏差。

Do I have to prove that the libstdc++ is MISRA compliant? 我是否必须证明libstdc ++符合MISRA?

There is no way to prove it, since it is not. 没有办法证明它,因为事实并非如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 libstdc++ 中的 Linux C++ 共享库构造函数段错误 - Linux C++ shared library constructor segfaults in libstdc++ libstdc ++不实现std :: stoi吗? - Does libstdc++ not implement std::stoi? g ++无法识别-stdlib = libstdc ++ - g++ does not recognize -stdlib=libstdc++ 如何编辑和重新构建GCC libstdc ++ C ++标准库源代码? - How to edit and re-build the GCC libstdc++ C++ standard library source? c ++ new运算符通过libstdc ++占用大量内存(67MB) - c++ new operator takes lots of memory (67MB) via libstdc++ 使用现代编译器编译的 C++ 项目,但链接到过时的 libstdc++ - C++ project compiled with modern compiler, but linked against outdated libstdc++ 如果在多个共享库中调用并且启用了 libstdc++ 静态链接,则 C++ 流会变坏 - C++ stream becomes bad if called in multiple shared libs and libstdc++ static linking is enabled 如何使用clang在osx上使用libstdc ++静态链接我的c ++程序? - How can i link my c++ program statically with libstdc++ on osx using clang? C ++ 11是否要求分配器是默认可构造的,libstdc ++和libc ++不一致? - Does C++11 require allocators to be default constructible, libstdc++ and libc++ disagree? 为什么 MISRA C++ 允许修改参数,而 MISRA C 不允许? - Why does MISRA C++ allow modifying parameters when MISRA C doesn't?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM