 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
ul Guest
|
Posted: Tue Dec 27, 2005 2:06 am Post subject: destruct incomple class. |
|
|
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
|
Posted: Tue Dec 27, 2005 6:45 pm Post subject: Re: destruct incomple class. |
|
|
"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 |
|
 |
|
|
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
|
|