Dynamic memory management and the use of pointers are critical topics in teaching the C++ language. They are also some of the most difficult for students to grasp properly. The responsibility of ensuring that students understand these concepts does not end with the instructor’s lectures—a library enhanced with diagnostics beyond those provided by the language’s run-time system itself is a useful tool for giving students more detailed information when their code fails.

We have designed such a toolkit, Dereferee, which students can incorporate into their code with minimal intrusion into the learning process. To demonstrate its effectiveness, we examine C++ code from students in a course that relied solely on the built-in memory management behavior of the language, without any significant additional diagnostic or debugging facilities. We instrument this code with Dereferee in order to explore the causes of errors that result in program crashes and to expose hidden faults that previously lay undetected. Dereferee provided enhanced diagnostics for bugs in 63% of student submissions, and pinpointed the source of 83% of abnormal program terminations. 95% of the students would have received extra diagnostic help from using Dereferee.

Dereferee is now included as part of our CxxTest distribution, so refer to that project for download information.

For more information: