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]

Bug? Or am I doing something really stupid... ?



Hi,

The following code:

    class Base { };
    
    class A : public Base
    {
    private:
      int y;
    
    public:
    
      static class B
      {
      public:
        int x;
        B() : x(0) { }
        ~B() { }
      } _dummy;
    
      A() : y(_dummy.x) { }
    };
    
    A::B _dummy;
    
    int main()
    {
      A* p = new A;
      delete p;
      return 0;
    }

produces the following error:

    $ g++ undefined.cc 
    /tmp/ccOLEPlf.o: In function `A::A(void)':
    /tmp/ccOLEPlf.o(.A::gnu.linkonce.t.(void)+0x7): undefined reference to `A::_dummy'
    collect2: ld returned 1 exit status

Am I doing something really stupid here? Or is this a problem with g++?

/Mike

Ps.  $ g++ -v
     Reading specs from /usr/local/gcc-2.95.2/lib/gcc-lib/i586-pc-linux-gnu/2.95.2/specs
     gcc version 2.95.2 19991024 (release)

     The same error is produced at http://www.codesourcery.com/gcc-compile.shtml


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