Article View: comp.std.c++
Article #3829delete vs incomplete class type
From: Steven Correll
Date: Wed, 27 Mar 1996 15:46
Date: Wed, 27 Mar 1996 15:46
42 lines
2505 bytes
2505 bytes
What must a conforming compiler do when confronted with this?
struct x;
struct y;
void
p(x *arg0, y *arg1)
{
delete [] arg0;
delete arg1;
}
Section 5.3.5 of my 5/95 copy of the draft standard says "If the object
being deleted has incomplete class type at the point of deletion and the
class has a non-trivial destructor...the behavior is undefined." Is this
still true?
I don't see how a compiler could avoid noticing that it hasn't a clue what
destructor to invoke at compilation time. Is there a reason (aside from
encouraging people to migrate to Java) not to require the compiler to
diagnose this as an error, instead of allowing it to fault at execution
time? (Given that x and y might be PODS, I doubt that it's possible to
defer the solution to execution time, but if it is, then why not define
the behavior and mandate that it be correct?)
Forgive me for being testy, but I've spent days debugging this error in a
program generated with the Solaris 3.0.1 compiler, where the undefined "delete"
for "arg0" in the example above can cause a failure during a perfectly correct
and well-defined "delete" of a totally unrelated object (the undefined "delete"
deallocates memory but fails to remove an entry from a table in the runtime
library; if the "new" of the other object happens to reuse the same block of
memory, it puts a redundant entry into the table, and a well-defined "delete"
of that object blows up.)
--
Steven Correll == PO Box 66625, Scotts Valley, CA 95067 == sjc@netcom.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 ]
Technical Details
Message-ID:
<sjcDownA7.6FA@netcom.com>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: sjc@netcom.com (Steven Correll) Newsgroups: comp.std.c++ Subject: delete vs incomplete class type Date: 27 Mar 1996 15:46:53 GMT Organization: NETCOM On-line Communication Services (408 261-4700 guest) Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <sjcDownA7.6FA@netcom.com> NNTP-Posting-Host: taumet.eng.sun.com Apparently-To: comp-std-c++@uunet.uu.net Content-Length: 1578 X-Lines: 35 Originator: clamage@taumet