Skip to content

Instantly share code, notes, and snippets.

@gjasny
Created January 22, 2014 07:12
Show Gist options
  • Save gjasny/8554662 to your computer and use it in GitHub Desktop.
Save gjasny/8554662 to your computer and use it in GitHub Desktop.
Intel Compiler Crash
#include <iostream>
struct InterfaceA {
virtual void foo() = 0;
};
struct InterfaceB {
virtual void bar() = 0;
};
class ImplA : virtual public InterfaceA
{
public:
ImplA(InterfaceB* p) : m_p(p)
{
}
void foo() {
std::cout << "foo\n";
m_p->bar(); // <- SEGFAULT
}
private:
InterfaceB* m_p;
};
class ImplB : virtual public InterfaceB, public ImplA
{
public:
ImplB() : ImplA(this)
{
}
void bar() {
std::cout << "bar\n";
}
void doSth() {
foo();
}
};
int main()
{
ImplB* p = new ImplB();
p->doSth();
// delete p;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment