Bug? Or am I doing something really stupid... ? [SOLVED]
Mike Harrold
mharrold@cas.org
Wed Mar 14 10:04:00 GMT 2001
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
>
>
More information about the Gcc-bugs
mailing list