optimization bug

Kaoru Fukui k_fukui@highway.ne.jp
Sun Oct 25 21:47:00 GMT 1998


Hi!
I have the same problem.
I am useing egcs-1.1branch  from cvs  at 22th Oct. gcc version egcs-2.91.57.


$ cat test.cxx
#include <iostream.h>
class BaseClass {
  public:
        virtual void SayHello() = 0;
};
int main()
{
        class LocalClass : public BaseClass {
          public:
                void SayHello() { cout << "Hello" << endl; }
        };
        LocalClass l;
        l.SayHello();
        return 0;
}

When compiled with -O0  is Ok, But----

$ g++ test.cxx
$ ./a.out
Hello

When compiled with -O2 is fail.

$ g++ -O2 test.cxx
/tmp/cc90fTLK.o(.gnu.linkonce.d._vt.Q26main.0_10LocalClass+0xc): \
	undefined reference to `SayHello__Q26main.0_10LocalClass.280'
collect2: ld returned 1 exit status

Thanks 
Kaoru Fukui
k_fukui@highway.ne.jp


More information about the Gcc-bugs mailing list