In the following example the constructor of stc_a is not called at startup, so the vtable is 0 and the program crashes at the call to foo() through a pointer to stc_a.With stc_a_dummy (using the constructor with one argument) everything works fine.///////////////////////////////////////////////////////////////////////////////#include <tchar.h>class a {public: a() {} a(bool dummy) {} virtual void foo() const {}};__declspec( selectany ) extern const a stc_a; // <-- not initialized at startup__declspec( selectany ) extern const a stc_a_dummy(false);int _tmain(int argc, _TCHAR* argv[]){ stc_a.foo(); const a* ptr_a_dummy = &stc_a_dummy; ptr_a_dummy->foo(); const a* ptr_a = &stc_a; ptr_a->foo(); // <-- crash ! return 0;}
Visual Studio/Silverlight/Tooling version
What category (if any) best represents this feedback?
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results
Please wait...