JSF++ AV Coding Standard NL
JSF++ AV Coding Standard NL
Overview
Why C++? Design philosophy of JSF++ Examples of rules Summary
Achieved full US JPO and UK JCA agreement that C++ can be used in safety-critical software.
Application
Complexity
Language Tools
10
JSF++
MISRA is a subset of C C Allows unsafe code that C++ rejects JSF++ is a subset of MISRA (with respect to C) JSF++ is a subset of ISO C++ C++ provides facilities that allow the banning of, or isolation of, MISRA C dangerous C/C++ features
Libraries, primarily relying on simple templates, are used to provide cleaner, safer alternatives to known problem areas of C and C++ Simple Libraries Safer Alternatives
JSF++
C++
11
Note: C++ facilities such as templates and virtual functions can be used to eliminate most casts (explicit type conversions)
12
Feedback
No standard is perfect We expect to refine JSF++ based on feedback Lockheed_martin developers The embedded systems community The C++ community Tool builders Please comment!
13
JSF++ overview
231 rules 11 pages of front matter table of contents, terminology, references, etc. 58 pages of rules 76 page Appendix A with more extensive rationale and examples
14
Rules
Each rule contains either a should, will or a shall in bold letters indicating its type. Should rules are advisory rules. They strongly suggest the recommended way of doing things. Will rules are intended to be mandatory requirements. It is expected that they will be followed, but they do not require verification. They are limited to non-safety-critical requirements that cannot be easily verified (e.g., naming conventions). Shall rules are mandatory requirements. They must be followed and they require verification (either automatic or manual). Breaking a Should rule requires one level of management approval Breaking a Will or Shall rule requires two levels of management approval (and documentation in code for Shall rules)
15
16
// Wrong: ++p evaluated twice // Correct: ++p evaluated once and type // checking performed. (q is const)
17
18
19
20
21
22
Correct Size?
void f(Array<Point_3d>& a) { const uint32 n = a.size(); for (uint32 i=0 ; i<n ; ++i) { // process elements } }
Size encapsulated
23
24
25
C++98 catches most violations at compile time C++0x can express and enforce such requirements (concepts)
26
27
28
29
Summary
Provide safer alternatives to known unsafe facilities Note: cannot be accomplished via subsetting alone Simple template-based libraries created to provide cleaner, safer alternatives to known problem areas of C and C++ Rule-set crafted to specifically address undefined behavior Restricts programmers to a better specified, more analyzable, and easier to read (and write) subset of C++ Eliminates large groups of problems by attacking their root causes
31
Summary
Banned features with behaviors that are not 100% predictable Free store allocation Exception handling Automated enforcement mechanisms used whenever possible Achieved full US JPO and UK JCA agreement
32
Best Practices
Coding Standard includes guidance on topics including Arrays and pointers Constructors/destructors Object initialization Inheritance hierarchies Templates C++-style casts Namespaces Statement complexity
33
34
Contributors
The design of JSF++ involved many people Internal and external reviews Key contributors Bjarne Stroustrup Kevin Carroll Mike Bossert (JPO) John Colotta Paul Caseley and Mike Hill (UK) Randy Ethridge Greg Hickman Michael Gibbs Mike Cottrill Tommy Gitchell John Robb Ian Hennell
35
Additional Information
1. JOINT STRIKE FIGHTER AIR VEHICLE C++ CODING STANDARDS FOR THE SYSTEM DEVELOPMENT AND DEMONSTRATION PROGRAM. Document Number 2RDU00001 Rev C. December 2005. JSF++ http://www.research.att.com/~bs/JSF-AV-rules.pdf ISO/IEC 14882:2003(E), Programming Languages C++. American National Standards Institute, New York, New York 10036, 2003. Bjarne Stroustrup: Abstraction and the C++ machine model. Proc. ICESS'04. December 2004. Also in Springer LNCS 3605. Enbedded software and systems. 2005. Bjarne Stroustrup. The C++ Programming Language, 3rd Edition. Addison-Wesley, 2000. Lois Goldthwaite (editor): Technical Report on C++ Performance. WG21 N1487=03-0070. 2003-08-11. Motor Industry Software Reliability Association. Guidelines for the Use of the C Language in Vehicle Based Software, April 1998. MISRA C (old think) . Scott Meyers. Effective C++: 50 Specific Ways to Improve Your Programs and Design, 2nd Edition. Addison-Wesley, 1998. More references in [1]
2. 3.
4. 5. 6.
36