Topic: Incomplete types (was Forward decls &
Author: clamage@Eng.sun.com (Steve Clamage)
Date: 1996/06/13 Raw View
In article 1206960637420001@rph.bluefin.net, bobh@hablutzel.com (Bob Hablutzel) writes:
>
>Forgive me if this has been covered, as I have just discovered this group
>(and this thread), but doesn't deleting an object whose declaration is
>incomplete allow for the possibility of protection violations? In other
>words, if the declaration of the class makes operator delete or the
>destructor private/protected, then the delete would have been allowed for
>an object that should not be deleted.
It allows for the possibility of anything. The results of the delete
operation are undefined (meaning anything can happen) if the incomplete
type has a non-trivial destructor or a deallocation function.
A good defensive programming rule is not to delete objects whose type
is incomplete. The compiler can easily provide such warnings, and
some do (Sun C++, for example).
Whether the language rule should be changed to disallow delete-ing
an object whose type is incomplete is a separate subject.
---
Steve Clamage, stephen.clamage@eng.sun.com
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]