Hi there,
I believe I've found an issue with a specific combination of object
instantiations and the alloca() function. It appears that the compiler
miscalculates the placement of ESI on the stack, so in a debug build, the
__RTC_CheckEsp() stack checker function throws up the following warning:
"Run-Time Check Failure #0 - The value of ESP was not properly saved across
a function call. This is usually a result of calling a function declared
with one calling convention with a function pointer declared with a different
calling convention."
I've attached the code below and it should be reproducible by creating a new
win32 c++ project and just running and building it in debug.
Thanks for your attention. If you can confirm my results, please let me
know. I've tested it against the original VC++ 2003 and similar code causes
the same issue with SP1. I'll update when I get to try it on VS2005.
Rich
/////////////////////////
#include <malloc.h>
#include <windows.h>
class ClassWithDestructor
{
public:
~ClassWithDestructor() {} // Destructor needed
};
class AlignedMember
{
__declspec(align(32)) int a; // Needs an aligned member
public:
AlignedMember() {} // Constructor needed
};
class Application
{
public:
virtual bool Application::render() // Needs to be virtual
{
ClassWithDestructor classWithDestructor;
int *myInt = (int *)alloca(sizeof(int));
AlignedMember alignedMember;
return true;
}
bool callRender() { return render(); } // Needs a wrapper to the virtual
virtual ~Application() {}
};
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
Application application;
return application.callRender();
}