g++3: Static Initializers occur twice in Binary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

in the attached example, the constructor of class A is generated twice.
I have tested thish with g++-3.3.2 and g++-3.2.3. "objdump -tC" shows
two occurences of constructor A::A. Please could anyone tell me how to
prevent this behavior? g++-2.95 produced only one constructor.

  #include <iostream>

  class A
  {
  public:
    A();
    A(const A&);
  };

  A::A()
  {
    std::cout << "hello" << std::endl;
  }

  int
  main(int argc, const char *argv[])
  {
    static A _a;
  }

Frank
-- 
## Dept. of Computer Science, Dresden University of Technology, Germany ##
## http://os.inf.tu-dresden.de/~fm3                                     ##

Attachment: pgp00008.pgp
Description: signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux