Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Destructor ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 14 of 16 Topic 9528 of 9828
Post > Topic >>

Re: Destructor not called with forward declaration instead of include

by Seungbeom Kim <musiphil@[EMAIL PROTECTED] > Apr 26, 2008 at 08:42 AM

Vidar Hasfjord wrote:
> On Apr 22, 6:13 pm, Brendan <catph...@[EMAIL PROTECTED]
> wrote:
>> What I'm actually iffy on, is why you can compile code that deletes a
>> pointer to an incomplete type at all. This compiles with only a
>> warning about deleting a pointer to an incomplete type on VC9.

I'm also curious.

> I agree that the standard should at least require a diagnostic if
> doesn't already do so. I guess forbidding it is difficult because it
> actually works fine when the type has a trivial destructor.

You mean, when the type is incomplete but has a trivial destructor?
Does that help much? What do we lose by requiring the type to be
complete at a 'delete' expression with a pointer to that type?
(On the other hand, we gain a lot of correctness assurance!)

> An interesting question is what is the minimal type information
> required for the compiler to handle this correctly? Could a language
> extension allow this to be handled without requiring the full type to
> be revealed (and thus require the user to break encapsulation or
> redesign the class hierarchy). Could the following be enough?
> 
>    virtual class Clazz; // I have a virtual destructor, promise!

I guess the compiler may need the complete class definition even
just to invoke the virtual destructor; e.g. it has to know which
entry in the vtable represents the destructor.

-- 
Seungbeom Kim

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




 16 Posts in Topic:
Destructor not called with forward declaration instead of includ
internetpet <internetp  2008-04-21 20:43:18 
Re: Destructor not called with forward declaration instead of in
=?ISO-8859-1?Q?Daniel_Kr=  2008-04-22 10:54:58 
Re: Destructor not called with forward declaration instead of in
Triple-DES <DenPlettfr  2008-04-22 10:52:59 
Re: Destructor not called with forward declaration instead of in
Travis Vitek <travis.v  2008-04-22 10:53:33 
Re: Destructor not called with forward declaration instead of in
marlow.andrew@[EMAIL PROT  2008-04-22 11:07:11 
Re: Destructor not called with forward declaration instead of in
Maciej Sobczak <see.my  2008-04-22 11:13:17 
Re: Destructor not called with forward declaration instead of in
alasham.said@[EMAIL PROTE  2008-04-22 11:18:19 
Re: Destructor not called with forward declaration instead of in
Brendan <catphive@[EMA  2008-04-22 11:13:28 
Re: Destructor not called with forward declaration instead of in
nickf3 <nickf3@[EMAIL   2008-04-22 11:43:17 
Re: Destructor not called with forward declaration instead of in
Alan Johnson <awjcs@[E  2008-04-22 11:43:18 
Re: Destructor not called with forward declaration instead of in
peter koch larsen <pet  2008-04-22 15:22:47 
Re: Destructor not called with forward declaration instead of in
Vidar Hasfjord <vattil  2008-04-23 13:13:18 
Re: Destructor not called with forward declaration instead of in
Triple-DES <DenPlettfr  2008-04-23 13:13:15 
Re: Destructor not called with forward declaration instead of in
Seungbeom Kim <musiphi  2008-04-26 08:42:07 
Re: Destructor not called with forward declaration instead of in
Carl Barron <cbarron41  2008-04-27 07:01:39 
Re: Destructor not called with forward declaration instead of in
Vidar Hasfjord <vattil  2008-04-27 07:44:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 15:56:54 CDT 2008.