Checkmate: cornering C++ dynamic memory errors with checked pointers

  • Authors:
  • Scott M. Pike;Bruce W. Weide;Joseph E. Hollingsworth

  • Affiliations:
  • Computer and Information Science, The Ohio State University, Columbus, OH;Computer and Information Science, The Ohio State University, Columbus, OH;Computer Science, Indiana University Southeast, New Albany, IN

  • Venue:
  • Proceedings of the thirty-first SIGCSE technical symposium on Computer science education
  • Year:
  • 2000

Quantified Score

Hi-index 0.00

Visualization

Abstract

Pointer errors are stumbling blocks for student and veteran programmers alike. Although languages such as Java use references to protect programmers from pointer pitfalls, the use of garbage collection dictates that languages like C++ will still be used for real-time mission-critical applications. Pointers will stay in the classroom as long as they're used in industry, so as educators, we must find better ways to teach them. This paper presents checked pointers, a simple wrapper for C++ pointers that prevents pointer arithmetic and other common sources of pointer errors, and detects all dereferencing and deallocation errors, including memory leaks. The syntax of checked pointers is highly faithful to raw C++ pointers, but provides run-time error detection and debugging information. After debugging, changing one #include is all that is required to substitute a non-checking implementation that is as fast as raw C++.