On 5/10/05, Christopher Faylor <[EMAIL PROTECTED]> wrote: > Previous to 1.5.16, static destructors were always called via a > gcc "atexit" mechanism. This meant that there were scenarios where > destructors would not be called at all so I made cygwin's exit call > the destructors explicitly. I just forgot to make cygwin do the right > thing when returning from main rather than exiting. This will be > fixed in the next snapshot.
There's one more glitch in this. The order of destruction of static objects should be the inverse of their order of construction, regardless of whether they are global or local. In 1.5.16 and the latest snapshot, global static objects are destroyed before local static objects, regardless of the order of construction. Here's a demo program: #include <stdio.h> struct A { int i; A(int p) : i(p) { printf("A::A(%d)\n", i); } ~A() { printf("A::~A for %d\n", i); } }; A a(1); void f() { static A a(3); } main () { static A a(2); printf("main\n"); f(); } In the new Cygwin versions, the output is: A::A(1) A::A(2) main A::A(3) A::~A for 1 A::~A for 3 A::~A for 2 The destructors should print 3, 2, 1 instead of 1, 3, 2. -- William M. (Mike) Miller [EMAIL PROTECTED] -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/