Referring to objects of incomplete class type, also known as forward declarations, is a common practice. One such common usage is with the "pimpl idiom" [Sutter 00] whereby an opaque pointer is used to hide implementation details from a public-facing API. However, attempting to delete a pointer to an object of incomplete class type can lead to undefined behavior. The C++ Standard, [expr.delete], paragraph 5 [ISO/IEC 14882-2014], states:
If the object being deleted has incomplete class type at the point of deletion and the complete class has a non-trivial destructor or a deallocation function, the behavior is undefined.
...
[Dewhurst 03] | Gotcha #39, "Casting Incomplete Types" |
[ISO/IEC 14882-2014] | Subclause 4.10, "Pointer Conversions" |
[Sutter 00] | "Compiler Firewalls and the Pimpl Idiom" |
...