TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  OAL#005Checked automatically with code checker

This rule is Obsolete
Synopsis:Assign a new value to a pointer that points to deallocated memory
Severity Level:9
Category:Object Allocation


Pointers that point to deallocated memory should either be set to nullptr or to other allocated memory to prevent access to the released memory. If a pointer is not set to a new value it results in undefined behavior when it is accidentally used. If a pointer, which is set to nullptr, is accidentally used it will result in an exception. Also try to prevent this by limiting the block scope of such invalidated pointers or references.
Of course smart pointers are the preferred way of using memory.

Exceptions to this rule are smart pointers and in case pointer lifetime ends.

Data members should not have to be reset in destructors.