This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
C++ regression: constructors of static class variables not called
- To: gcc-bugs at gcc dot gnu dot org
- Subject: C++ regression: constructors of static class variables not called
- From: Gerald Pfeifer <pfeifer at dbai dot tuwien dot ac dot at>
- Date: Thu, 24 Aug 2000 21:38:27 +0200 (CEST)
- cc: "David O'Brien" <obrien at nuxi dot com>, Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
Fun, fun, fun, creating a minimal test case out of several thousands
line of code.
With GCC 2.95.2 (as shipped with FreeBSD 4.1) we get
constructor
constructor
auto
static
with current CVS sources on i386-unknown-freebsd4.1 we get
constructor
auto
static
Segmentation fault (core dumped)
It seems we fail to invoke the constructor of the static class variable.
Note: I cannot reproduce this on i686-pc-linux.
Gerald
---- cut ----
#include <map>
#include <iostream>
struct NAMESTABLE
{
map<int,int> lookup;
NAMESTABLE()
: lookup()
{
cout << "constructor" << endl;
}
void add(const char *s, const int &item)
{
cout << s << endl;
lookup.insert(pair<int,int>(item,0));
}
};
NAMESTABLE q;
int main() {
NAMESTABLE p;
p.add("auto",1);
q.add("static",1);
}