From owner-freebsd-hackers Sat May 31 17:52:32 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id RAA25803 for hackers-outgoing; Sat, 31 May 1997 17:52:32 -0700 (PDT) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id RAA25793 for ; Sat, 31 May 1997 17:52:25 -0700 (PDT) Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id CAA01169; Sun, 1 Jun 1997 02:52:18 +0200 Received: (from j@localhost) by uriah.heep.sax.de (8.8.5/8.8.5) id CAA02488; Sun, 1 Jun 1997 02:40:43 +0200 (MET DST) Message-ID: <19970601024043.PG35696@uriah.heep.sax.de> Date: Sun, 1 Jun 1997 02:40:43 +0200 From: j@uriah.heep.sax.de (J Wunsch) To: freebsd-hackers@freebsd.org (FreeBSD hackers) Cc: un_x@anchorage.net (Steve Howe) Subject: Re: Borland 16bit bcc vs cc/gcc (float) References: <1.5.4.32.19970531220152.008b46f0@mindspring.com> X-Mailer: Mutt 0.60_p2-3,5,8-9 Mime-Version: 1.0 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <1.5.4.32.19970531220152.008b46f0@mindspring.com>; from Kevin P. Neal on May 31, 1997 18:01:52 -0400 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk As Kevin P. Neal wrote: > Who says you always have to use exit()? > > In fact, I've observed C++ code that never calls the destructors if you > exit() of out a program. Global destructors should be called. Destructors for objects local to main(), of course, not. j@uriah 119% cat foo.cc #include #include class myobj { static int count; public: myobj() { cout << "Created my object # " << ++count << "\n"; } ~myobj() { cout << "Destroyed my object, " << --count << " remaining.\n"; } }; int myobj::count = 0; myobj y; int main(int argc, char **argv) { myobj x; if (argc > 1) exit(0); } j@uriah 120% c++ foo.cc j@uriah 121% ./a.out Created my object # 1 Created my object # 2 Destroyed my object, 1 remaining. Destroyed my object, 0 remaining. j@uriah 122% ./a.out "call exit() now" Created my object # 1 Created my object # 2 Destroyed my object, 1 remaining. -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)