This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug? Or am I doing something really stupid... ? [SOLVED]
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Bug? Or am I doing something really stupid... ? [SOLVED]
- From: Mike Harrold <mharrold at cas dot org>
- Date: Wed, 14 Mar 2001 13:03:55 -0500 (EST)
Someone has already pointed out to me the error of my ways.
A real "Doh!" mistake if ever there was one!
/Mike
Forwarded message:
> 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
>
>