This is the mail archive of the
pthreads-win32@sources.redhat.com
mailing list for the pthreas-win32 project.
Re: About exit4.c
- From: Pietrobon Marcello <teiffel at attglobal dot net>
- To: Pthreads Developers List <pthreads-win32 at sourceware dot cygnus dot com>
- Date: Sun, 24 Feb 2002 00:38:55 -0600
- Subject: Re: About exit4.c
- References: <3C787EE3.C9C6365E@attglobal.net>
Even if it is not important It might be good to know about an other bug (probably) of the Microsoft compiler (which I
discovered trying to fix the problem with exit4.c):
The following code:
----------------------------------
#include <stdio.h>
class CheckDestructor
{
public:
CheckDestructor() { printf("CheckDestructor"); };
~CheckDestructor() { printf("~CheckDestructor"); };
};
void f()
{
CheckDestructor check;
throw 1;
}
int main(int argc, char* argv[])
{
//try
//{
f();
//}
//catch (...) {
// printf("inside catch(...)\n");
//}
return 0;
}
----------------------------------
doens't call the destructor ~CheckDestructor().
But it does that if we put f() inside the try... catch block
The reason is that main() is called from crt0.c inside a __try ... __except block, which does not call the destructor.
This violates the Ansi C++ specification dec96: see
http://www.codeproject.com/cpp/ANSI-cpp-dec96/except.asp
where 15.2 Constructors and destructors [except.ctor].
Best Regards,
Marcello