C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

destruct incomple class.

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
ul
Guest





PostPosted: Tue Dec 27, 2005 2:06 am    Post subject: destruct incomple class. Reply with quote



Hello everybody.

I have read that

"The C++ Standard allows, in 5.3.5/5, pointers to incomplete class
types to be deleted with a delete-expression. When the class has a
non-trivial destructor, or a class-specific operator delete, the
behavior is undefined."

Could someone bring the example in the topic, or give short
explanation, why?

Thanks


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

Back to top
Bo Persson
Guest





PostPosted: Tue Dec 27, 2005 6:45 pm    Post subject: Re: destruct incomple class. Reply with quote




"ul" <yuliy (AT) gmx (DOT) de> skrev i meddelandet
news:1135628969.410869.112210 (AT) g43g2000cwa (DOT) googlegroups.com...
Quote:
Hello everybody.

I have read that

"The C++ Standard allows, in 5.3.5/5, pointers to incomplete class
types to be deleted with a delete-expression. When the class has a
non-trivial destructor, or a class-specific operator delete, the
behavior is undefined."

Could someone bring the example in the topic, or give short
explanation, why?


Here is an example, suppose you have:

struct incomplete;

incomplete* get_one();

void func()
{
incomplete* p = get_one();

delete p;
}

This is allowed, I guess for C compatibility, as long as incomplete
doesn't have a destructor. The compiler cannot know that it should
call the destructor, or possibly an operator delete(), defined in
another source file.


Bo Persson




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


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.