The Detection of Dangling References in C++ Programs RICHARD A. EYRE-TODD University of Edinburgh The smart pointer functionality of the is a programming technique for the C++ language that extends the been used to support simple pointer. Smart pointers have previously persistence, distributed objects, reference counting, and garbage collection. This article will show how smart pointers can provide an inexpensive method for detecting dangling pointers to dynamic objects that can be added to any standard C++ implementation. Categories and Subject Descriptors: D.1.5 [Programming Techniques]: Object-Oriented ProEngineering]: Testing and Debugging-debugging aids; D.3.3 gramming; D.2.5 [Software [Programming Languages]: Language Constructs and Features data types and structures; dynamic storage management General Terms: Languages, Reliability Additional Key Words and Phrases: Dangling pointers, smart pointers INTRODUCTION The classic dangling reference problem, where a pointer references storage space that has been deallocated, is usually very difilcult to detect and trace. Language run-time systems commonly do not provide any protection against dangling so. The substitutes [Stroustrup tent objects 1992; reference C++ errors due to the overhead 1991] to that maybe the incurred by doing of pointer pointers persis[Coplien garbage language that add [Stroustrup functionality allows the basic construction pointer. Smart 1987] and variations thereof have
/lp/association-for-computing-machinery/the-detection-of-dangling-references-in-c-programs-K8HC059cDp