Guidance on Errors in C++
The last few years have seen a dramatic increase in the use of software. Software in fact is used increasingly in safety-critical applications such as airplanes,automobiles, power plants. medical devices, and many others. Frequently, the progamming language C++ are chosen for these applications. Studies [Binkley, NUREG - see below] indicate there may be several difficulties in using these languages in such safety-critical applications. We highlight some of these potential problems abd indicate some mechanisms to either prevent or detect faults before systems are delivered for operation. A fault is the result of an error in the code, and, if executed, could cause a failure.
In the following charts we provide guidance to those using C++ to develop software systems, to help them to avoid common mistakes and to be aware of more difficult faults which are likely to happen when programming for C++. There are 5 categories of problems. Each category has several specific error types. Each of these is identified with prevention and detection techniques. These are intended as guidance, not as guarantees. In fact, for those errors not addressed completely, we welcome your suggestions. Please send them, with your rationale for those techniques to D. Wallace dwallace@nist.gov
The prevention techniques are to be practiced during the programming of the software. They consist of suggestions for the programmer to consider or practices to follow. In some cases, static analysis tools, such as compilers, will check for these faults. Code walkthroughs, code reviews, and inspections can be applied to all the problems, that is, conduct these activities with a focus on uncovering the specific problem type or lack of appropriate code to prevent the problem.
Detection techniques are to be exercised on the code. The guidance provides some insights about what should the test do to identify if a specific error exists in the code.
| Errors Associated with Variables |
| Errors Associated with Memory |
| Errors Associated with Control Flow |
| Errors Associated with Functions |
| Errors Associated with Operators |