Hello, One of things mingw32 C runtime lacks is an implementation of __cxa_atexit. However, as explained in the comment below, some of the behaviour of __cxa_atexit is already in the C runtime atexit implementation.
Adding the object below to libstdc++ or libgcc.a and configuring with __cxa_atexit enabled produces PASSES for the three __cxa_atexit dependent testcases. It works fine in tests with destruction of objects in dll's too, whether these dlls are unloaded at process exit or by earlier calls to UnloadLibrary. (No, it doesn't allow exceptions to be thrown and caugtht across dll boundaries -- thats another story for gcc 4.3 -- but it removes one obstacle.) Although this keeps the changes local to mingw32 code, I don't really like adding a fake __cxa_atexit to a runtime lib. So, the other option would be to add a 'if (flag_use_dllonexit)' code to cp/decl.c and decl2.c to parallel flag_use_cxa_atexit. Adding a real __cxa_atexit to mingw runtime is of course also possible, but I thought I'd attempt the easy options first. I would appreciate any comments. Danny /* mingw32-cxa_atexit.c Contributed by Danny Smith ([EMAIL PROTECTED]) Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* On mingw32, each dll has its own on-exit table, which is initialized on dll load, Calls to atexit or onexit will register functions in the on-exit table of the containing module. Each dll-specific on-exit table runs when that dll unloads. The calls to atexit from the main app, (ie, including all static libs) are finalized at process exit. cc1plus currently ignores the argument to __cxa_atexit-registered functions. If that changes, we will need to replace this with a real __cxa_atexit implementation in mingw runtime. */ #include <stdlib.h> /* We don't need an explicit dll handle. The handle is always 'this'. */ void* __dso_handle = NULL; int __mingw_cxa_atexit (void (*)(void *), void *, void *); int __mingw_cxa_atexit (void (*func)(void *), void *arg __attribute__((unused)), void *d __attribute__((unused))) { return atexit ((void (*) (void)) func); } int __cxa_atexit (void (*)(void *), void *, void *) __attribute__ ((alias ("__mingw_cxa_atexit")));