This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: About exit4.c



[...uncaught exceptions...]

> This violates the Ansi C++ specification...

Nope.

FYI:

http://groups.google.com/groups?as_umsgid=3C75280D.571C0C0A%40web.de
http://groups.google.com/groups?as_umsgid=3C7633AF.4A08EFBF%40web.de
http://groups.google.com/groups?as_umsgid=3C741E98.BFA02412%40web.de
http://groups.google.com/groups?as_umsgid=3C77AFCB.481D2587%40web.de

regards,
alexander.


Pietrobon Marcello <teiffel@attglobal.net>@sources.redhat.com on 02/24/2002
07:38:55 AM

Sent by:  pthreads-win32-owner@sources.redhat.com


To:   Pthreads Developers List <pthreads-win32@sourceware.cygnus.com>
cc:
Subject:  Re: About exit4.c



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





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]