Topic: std::auto_ptr on incomplete type, take II.


Author: alfps@start.no (Alf P. Steinbach)
Date: Mon, 4 Oct 2004 20:03:39 +0000 (UTC)
Raw View
David Hilsee mentioned in a recent posting in [comp.lang.c++] that
<url: http://www.boost.org/libs/utility/checked_delete.html> mentions the
place in the standard that (implicitly, it seems to me) allows delete of a
pointer to incomplete type, namely    5.3.5/5, which states


  If the object being deleted has incomplete class type at the point of
  deletion and the complete class has a nontrival destructor or a
  deallocation function the behavior is undefined.


I think this explicit statement of Undefined Behavior is not necessarily a
statement that the behavior is Defined Behavior in other cases of incomplete
type, so where is that stated in the standard (if stated at all)?

Second, even allowing that the above or somewhere else means it's OK to delete
a pointer to class object of incomplete type in other cases, what is the
situation with respect to std::auto_ptr?  Is std::auto_ptr a "template
component"?  If so,    17.4.3.6/2 says it's UB to instantiate it on an
incomplete type.

Shouldn't "template component" be defined somewhere?

Shouldn't the situation wrt. delete of pointer to class object of incomplete
type, and std::auto_ptr ditto, be more clearly defined?


--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]