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

Rule:  OAL#005Checked automatically with code checker

Synopsis:Assign a new value to a pointer that points to deallocated memory
Language:C++
Severity Level:9
Category:Object Allocation


Description:

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.



Literature References:
Ellemtel Rec. 59
ISC++ Rule 8.3