From 5212832436454959376
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,327d55d23ac807ba,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2004-04-15 10:10:12 PST
Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!feed1.news.rcn.net!rcn!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: dsp@bdal.de (=?ISO-8859-1?Q?=22Daniel_Kr=FCgler_=28nee_Spangenberg=29=22?=)
Newsgroups: comp.std.c++
Subject: atexit and/or objects with global storage duration
Date: Thu, 15 Apr 2004 17:10:10 +0000 (UTC)
Lines: 77
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <407E38E8.8020008@bdal.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: mail2news.demon.co.uk 1082049010 12804 10.0.0.1 (15 Apr 2004 17:10:10 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Thu, 15 Apr 2004 17:10:10 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 1BEANN-0003KN-00
	for mail2news@news.news.demon.net; Thu, 15 Apr 2004 17:10:09 +0000
X-Received: from mulga.cs.mu.OZ.AU (localhost [127.0.0.1]) by mulga.cs.mu.OZ.AU with ESMTP
	id i3FHA6i2004506; Fri, 16 Apr 2004 03:10:06 +1000 (EST)
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i3FHA6F5004497;
	Fri, 16 Apr 2004 03:10:06 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.0.2) Gecko/20030208 Netscape/7.02
X-Accept-Language: de-de, de
X-Newsgroups: comp.std.c++
X-Spam-Checker-Version: SpamAssassin 2.60-mulga_r1 (1.212-2003-09-23-exp) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=0.1 required=5.2 tests=AWL autolearn=no 
	version=2.60-mulga_r1
X-MIME-Autoconverted: from 8bit to quoted-printable by mulga.cs.mu.OZ.AU id i3FHA6i2004506
Xref: archiver1.google.com comp.std.c++:1659

Hello community,

yesterday night I stumbled about a problem, for which I could not find=20
an answer in the
current C++ standard (2003). Please consider the following program:

//-------------------------------------------
#include <iostream>
#include <ostream>

struct A{
  ~A() {
    std::cout << "Bye-bye world" << std::endl;
  }
};

struct B {
  ~B()  {
     static A a;
   }
};=20

B b;

int main(){}
//-------------------------------------------

Is this program wellformed or does it lead to undefined behaviour? To=20
make my
point somewhat more clear, please consider the following alternative=20
program, which
should (to my opinion) have the same observable effect (at least if I=20
interpret correctly
the usual answer of standardists considering the equivalent behaviour of=20
functions
registered with atexit and the denstruction sequence of objects with=20
global storage
duration):

//-------------------------------------------
#include <iostream>
#include <ostream>
#include <cstdlib>

void a() {
    std::cout << ""Bye-bye world" << std::endl;
};

void b() {
  std::atexit(a);
};=20

int main(){
  std::atexit(b);
}
//-------------------------------------------

My basic question is, whether the call of atexit (or its equivalent)=20
**following** the call of exit
(which implicitely happens after leaving the main function) is a=20
wellformed process. I could not find
anything in the standard, what contradicts to that assumption, but am I=20
right?

Thanks for your help,

Daniel Kr=FCgler




---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



