add a check for correct order of destructor calls (from the gcc mailing

list) which points at a misconfiguration at our side
(cxa_atexit not used)
This commit is contained in:
drochner 2007-09-17 17:37:48 +00:00
parent f9577d3ada
commit 9b1b051e89
5 changed files with 60 additions and 2 deletions

View File

@ -1,5 +1,6 @@
# $NetBSD: Makefile,v 1.14 2007/02/19 19:42:50 rmind Exp $ # $NetBSD: Makefile,v 1.15 2007/09/17 17:37:48 drochner Exp $
SUBDIR+= basename bzip2 config cut dirname grep gzip m4 make rtld sdiff sort xlint SUBDIR+= basename bzip2 c++ config cut dirname grep gzip m4 make rtld
SUBDIR+= sdiff sort xlint
.include <bsd.subdir.mk> .include <bsd.subdir.mk>

View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2007/09/17 17:37:48 drochner Exp $
SUBDIR= static_destructor
.include <bsd.subdir.mk>

View File

@ -0,0 +1,11 @@
# $NetBSD: Makefile,v 1.1 2007/09/17 17:37:48 drochner Exp $
PROG_CXX= static_destructor
NOMAN= # defined
regress:
./${PROG} > out && diff out ${.CURDIR}/expected
CLEANFILES+= out
.include <bsd.prog.mk>

View File

@ -0,0 +1,4 @@
constructor A
constructor B
destructor B : i = 1
destructor A : i = 10

View File

@ -0,0 +1,37 @@
/* $NetBSD: static_destructor.cc,v 1.1 2007/09/17 17:37:49 drochner Exp $ */
/*
* Tests proper order of destructor calls
* (must be in reverse order of constructor completion).
* from the gcc mailing list
*/
#include <iostream>
using namespace std;
class A
{
public:
int i;
A(int j) : i(j) { cout << "constructor A" << endl; }
~A() { cout << "destructor A : i = " << i << endl; }
};
class B
{
public:
A *n;
B() {
static A p(1);
n = &p;
cout << "constructor B" << endl;
}
~B() {
cout << "destructor B : i = " << n->i << endl;
n->i = 10;
}
};
class B x1;
int main (void) { return 0; }