10 ms·
Misra C++:2023
- convery 3y agoDirect link: https://misra.org.uk/product/misra-cpp2023/ https://misra.org.uk/product/misra-cpp2023/
- mgaunard 3y agoIt's 15 pounds. Can someone give the gist of it?
- ska 3y agoIt’s a standard for the use of c++ in critical systems. Basically a guide to techniques and language features you can and can’t use (or how) and still have very predictable/controllable system behavior.
- 1MachineElf 3y agoI recently watched this webinar[0] about it, presented by the company ParaSoft, which develops a static analysis tool and compliance reporting solution for businesses required to use MISRA C++[1]. [0] https://www.brighttalk.com/webcast/18694/602198 https://www.brighttalk.com/webcast/18694/602198 [1] bhttps://www.parasoft.com/white-paper/buyers-guide-static-code-analysis-for-embedded-development/?gtd=false https://www.parasoft.com/white-paper/buyers-guide-static-cod...
- josefx 3y agoAt least the wiki article on MISRA C cites multiple studies that consider the rules mostly pointless, in some cases outright counterproductive and basically accuses it of being only beneficial to companies selling compliance tools. If MISCRA C++ is anywhere as bad you might be better of avoiding it.
- almostnormal 3y agoWith strict rules anyone can write software that does not instantly fail horribly (e.g., if pointers are not allowed, there won't be a bad dereference (but that's not even in misra)). That helps outsourcing to the lowest bidder.
- sam_bristow 3y agoYou can get a reasonable flavour of thw type of rules by looking at the Autosar C++ standard. MISRA C++ 2023 is a massive improvement over the previous (2008) version.
- FirmwareBurner 3y agoGreat royalty free alterative to MISRA C: [1] Embedded System development Coding Reference guide - Software Reliability Enhancement Center, JAPAN [1] https://www.ipa.go.jp/publish/qv6pgp00000011mh-att/000065271.pdf https://www.ipa.go.jp/publish/qv6pgp00000011mh-att/000065271...
- ska 3y agoNot super helpful for c++. Note the previous MISRA std. predates “modern” c++, as do some others.
- FirmwareBurner 3y agoAh, my bad, I misread the titles as being MIRA C, not C++.
- pjmlp 3y agoAdditionally this is the update for C++17.
- Longhanks 3y ago...which has been surpassed by two ISO standards already, with the third one on the road.
- lichtenberger 3y agoAt least they are already discussing the next version.
- ska 3y agoThat’s not really a big deal in this context. Getting over the 2011 change was a big jump, and basically makes modern c++ usable for many more projects. Lots of toolchains are pretty conservative also, 2017 is pretty new there. And much like the ISO standard, updates should be a lot easier now.
- xjia 3y agoIf you are interested in this, take a look at NaiveSystems Analyze [0] which is a free and open source static analyzer for checking MISRA compliance etc. Disclaimer: I'm the founder. It has been battle tested with real customers in automotive, medical devices, and semiconductors. AFAIK this is the first FOSS tool that achieves commercial use standards (extensive ruleset coverage, low false positives based symbolic execution (which Coverity relies heavily on) and SMT solver, ...) [0]: https://github.com/naivesystems/analyze https://github.com/naivesystems/analyze
- ska 3y agoIt doesn’t support this version yet, right?
- xjia 3y ago2023 is supported in the enterprise edition but not in the community edition yet. We gradually move features from EE to CE as new features added to EE. So you can expect 2023 support in CE in the future :-)
- ska 3y agoGood stuff!
- hsaliak 3y agoWhen will that be? What’s a good way to contact for enterprise support that covers misra 2023?
- xjia 3y agoI'm not sure about the timeline because that depends on a lot of things. In the meantime I guess you could start with AUTOSAR C++14. MISRA C++:2023 is essentially built on top of that. For enterprise edition simply email to hello[AT]naivesystems.com as noted in the README on GitHub
- vodou 3y agoOne thing that surprised me a bit was that exceptions are more or less recommended in these guidelines. In the section "4.18 Exception handling", it is mentioned that "most compilers provide options (such as -fno-exceptions) that can be used to disable exceptions in order to eliminate the code and size overheads". Then it goes on describing how this makes it impossible to comply with a bunch of other rules. Since these are "guidelines for the use of C++17 in critical systems", I would have expected it to prohibit exceptions due to their non-determinstic nature. On a side note, dynamic memory is prohibited (rule 21.6.1). I haven't read the earlier MISRA C++ guidelines so I don't know if this have changed.
- otabdeveloper4 3y agoProhibiting exceptions is a toxic antipattern. Once you have more than one thread you want to propagate fatal errors in a sane way. ("Just crash the whole program, #yolo" is not a sane way.)
- shadowgovt 3y agoIt depends on the problem domain. For automotive embedded software? Definitely not. But Google, for instance, bans them in much of its server code under the principle that exceptions should denote circumstances where the entire program cannot recover and when a server node cannot recover, logging noisily and failing fast so that it can be restarted into a working state is preferable to trying to unwind a bad state. Given that constraint, they conclude that the overhead of maintaining exception unwinding and the non-local control flow aren't worth it.
- cpgxiii 3y agoThe classic GSG prohibition on exceptions has more to do with a lack of exception safety in their legacy code base than anything else. Promptly-crash-on-failure can be achieved by adopting a "don't catch exceptions" style, with significant advantages of not throwing away much of the strengths of RAII or needing the evil hack that is two-phase initialization.
- iaseiadit 3y agoFor those unfamiliar, these are standards published by the Motor Industry Software Reliability Association (MISRA) that provide guidelines for C++ and aim to promote safety, security, and reliability in embedded system software.
- cepacked 3y ago[dead]
- zengid 3y agoConfusing that they don't keep their name in line with the C++ version: MISRA C++:2023 Guidelines for the use C++:17 in critical systems
- cordenr 3y agoIt's an unfortunate coincidence. 2023 just happens to be when the MISRA committee finalised the document. The good news is that it's very unlikely to happen for any future document version.
- jes 3y agoCan you say how your tool compares to Vector PC-Lint in terms of analyzing compliance w/r/t MISRA C and C++?
- Longhanks 3y agoAh yes, the motor industry, which with the exception of Tesla delivers some of the world's most miserable, buggy, unpleasant-to-use infotainment software, crippled by bureaucracy, introduces more of the latter in order to micromanage software developers even more. Thanks, but no, thanks. I'd rather you completely stop developing software and just let me plug in my phone. The less software my car runs, the safer I feel, and I need nothing more but navigation and music, which my phone handles just fine.
- coumbaya 3y agoIn general you would apply MISRA only on some critical parts of the software, and the infotainment wouldn't be part of this. At least it was like this when I applied MISRA on high speed trains, and when I worked briefly at the company that invented the airbag, their infotainment box was a windows embedded with 0 SIL2+ software on it. (But I agree with your point tho).
- nanolith 3y agoMISRA isn't typically used in infotainment systems. It's used in safety critical systems, like the car computer, which manages the monitoring and adjustment of fuel to oxygen mixture in the engine.
- P_I_Staker 3y agoWouldn't be shocked if infotainment does too. What else should they use?
- nanolith 3y agoNone of the fancy infotainment systems I observed the last time I went car shopping were likely to use it. They were based on third party frameworks and tools -- e.g. Android -- that weren't or couldn't possibly be built following this standard. In general, systems that are safety critical or adjacent to such systems should use formal methods. On many newer vehicles, like the Tesla Cybertruck, the infotainment system also doubles as the instrument display, which makes it safety adjacent. As such, it should also use formal methods. Model checking, based on satisfiability, is a relatively low bar to achieve. MISRA is a decent idiomatic framework that brings one closer to safe coding practices. However, it's not foolproof. Formal methods in theory _is_, but in practice it is not. Defense in depth is useful for designing and writing software. A good idiomatic style, unit testing, and formal methods each provide complementary checks. So, my recommendation would be to choose a good idiomatic style -- and despite its relative complexity, MISRA is a good idiomatic style from a safety perspective. Then, build a good automated testing culture. Incorporate model checking, especially through any execution path that is safety critical. Finally, architect the system so that failures in things that don't matter (video, audio, "games", or navigation) don't impact things that do matter (instrument display or communication with critical systems).
- hgs3 3y agoI conformed to MISRA C:2012 for an open source project and what's unfortunate is the lack of open source static analyzers for verifying MISRA compliance. Aside from Cppcheck [1] all other analyzers I found are commercial/proprietary. It's surprising because Clang should make writing an analyzer easier than ever. [1] https://cppcheck.sourceforge.io/misra.php https://cppcheck.sourceforge.io/misra.php
- xjia 3y agoClang has its own limitations. And it takes more effort than just writing the checkers. We open sourced our previously proprietary static analyzer (mostly based on Clang but also integrated other useful tools) but the commercial/enterprise edition still has its own value in stability, quality assurance, and technical support. It's more like building a Linux distro (e.g. RHEL) from various FOSS components.
- josephcsible 3y agoIsn't the most likely reason that no FOSS tools support it that it's not an open standard?
- superfist 3y agoEach C/C++ guideline define language subset so de facto new language but with weak enforcement where in practice most organisations following it anyway create some specific exceptions from that guidelines. C/C++ world (C less) is a mess, it can't be fixed and this agony will be very long lasting.
- andrepd 3y agoIndeed. I don't want to be a shill but "safe C++" has a name, it's called Rust. C++ is such an incredibly complex language filled with such easy to set off footguns, that there is no way out of this mess without a non-backwards complete solution, like Rust.
- steveklabnik 3y agoA fun github repo: "what would MISRA look like applied to Rust" https://github.com/PolySync/misra-rust/blob/master/MISRA-Rules.md https://github.com/PolySync/misra-rust/blob/master/MISRA-Rul... (They're comparing with the C version, not the C++ version...)
- pelorat 3y agoI love C++ but it shouldn't need guidelines :(
- isityouyesitsme 3y agoWhy not? Each project has a unique blend of acceptable risks and non-functional requirements. I promise you, you'd hate C++ if you had to write each project, safety critical or not, according to the least common denominator feature set for safety critical domains.
- cordenr 3y agoAndreas Weis gave a talk at cppnow [0] describing how they develop software for cars. It's eye opening. I would imagine all languages will have at least some guidelines relating to how they're used. [0] https://youtu.be/mUFRDsgjBrE?si=KxEpoStcuvtxYFdg https://youtu.be/mUFRDsgjBrE?si=KxEpoStcuvtxYFdg
- parlortricks 3y agoI am a C (not C++ hobbyist), and I try to read up on standards and style guides to understand what I should be trying to do. Given that Misra has a C:2012, does anyone know how this compares to SEI Cert C Coding Standard (which im reading right now along with Secure Coding in C and C++)?
- cordenr 3y agoDefinitely a generalisation, but i would see them as two sides of the same coin. If Cert has something about an API, then it will have an example of misuse of it and then an example showing its correct use. MISRA might either prohibit it's use completely (if there's a safe alternative), or with require some boilerplate step be taken every time the API is used.
- bfrog 3y agoMisra is a specification for languages to specify and avoid undefined or underdefined behavior as I understand it, thus avoiding bugs. What if a language has no undefined behavior and dynamic allocation is easily disabled. What would misra rules say?
- hgs3 3y agoIn addition to avoiding undefined behavior, MISRA discourages language features that are "dangerous" like I/O and dynamic memory routines. It also defines some (controversial) styling rules, such as requiring functions to have exactly one exit point.
- cordenr 3y agoSE/SE is called out explicitly in the ISO26262 documents (functional safety in road vehicles). This makes it easy to defend the inclusion of such a guideline, even if you may not agree with it. But as it happens, MISRA C++:2023 doesn't have this guideline.
- bfrog 3y agono_std rust then which has no i/o or heap, and what misra rules would there even need to be?
- infima 3y agoAnother open-source project supporting, among others, previous iterations of MISRA C++ through CodeQL queries is https://github.com/github/codeql-coding-standards https://github.com/github/codeql-coding-standards