#include <iostream>
using namespace std;
class Base
{
public:
virtual void function1() {cout<<"Base :: function1()\n";};
virtual void function2() {cout<<"Base :: function2()\n";};
virtual ~Base(){};
};
class D1: public Base
{
public:
~D1(){};
virtual void function1() { cout<<"D1 :: function1()\n";};
};
class D2: public Base
{
public:
~D2(){};
virtual void function2() { cout<< "D2 :: function2\n";};
};
int main()
{
D1 *d = new D1;;
Base *b = d;
b->function1();
b->function2();
delete (b);
return (0);
}
It compiled with rvpc++ fine, but failed with rvpc++ and -O3 flag:
➜ logging-test rvpc++ simple.cpp
➜ logging-test rvpc++ simple.cpp -O3
/tmp/simple-6a473c.o: In function `Base::Base()':
/home/yiyiwang/logging-test/simple.cpp:4: undefined reference to `__rvpredict_vptr_update'
/tmp/simple-6a473c.o: In function `D1::D1()':
/home/yiyiwang/logging-test/simple.cpp:12: undefined reference to `__rvpredict_vptr_update'
/tmp/simple-6a473c.o: In function `main':
/home/yiyiwang/logging-test/simple.cpp:31: undefined reference to `__rvpredict_vptr_load'
/home/yiyiwang/logging-test/simple.cpp:32: undefined reference to `__rvpredict_vptr_load'
/home/yiyiwang/logging-test/simple.cpp:34: undefined reference to `__rvpredict_vptr_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Example code:
It compiled with
rvpc++
fine, but failed withrvpc++
and-O3
flag: