I'm trying to copy a wide c-string from one place into another. I'm using Visual Studio 2012 express on windows8 64-bit platform. It works perfectly fine unless i try to run the application on my main computer with Windows7 x64. It crashes instantly. No exception error though it's a messy crash with no trackable error code whatsoever. If you need more specific information about the crash itself i will try to provide it. When i comment out the copying the program works perfectly fine. So it's pretty obvious the problem is with the function itself. Here is the line that does all the copying:
virtual void CClass::ChangeText();
void CClass::ChangeText(float _f)
{
std::wstringstream wss;
wss << _f;
wcscpy(const_cast<wchar_t *>(this->m_lpszWideText),wss.str().c_str());
}
^ crashes on win7 / works on win8
My wild guess is that the new compiler uses a newer version of wmemcpy that just doesn't work on windows 7? Shouldn't the program crash only when it reaches the function call line though?
A Crash with String-Copy algorithms have usually two origins:
Your Source is not NULL-Terminated In Your Example this is not the case, because you extract it from wstringstream::c_str()
Your Destination is not big enough to handle the source data, and so is written out of Bounds. This may be the cause of your Crash, means, your this->m_lpszWideText is too small (please give the Declaration of it and, if it is dynamically allocated show us, how.)