Created
January 22, 2014 07:12
-
-
Save gjasny/8554662 to your computer and use it in GitHub Desktop.
Intel Compiler Crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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