This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C++ regression: constructors of static class variables not called


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);
    } 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]