C++ regression: constructors of static class variables not called
Gerald Pfeifer
pfeifer@dbai.tuwien.ac.at
Thu Aug 24 12:38:00 GMT 2000
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);
}
More information about the Gcc-bugs
mailing list