Avoiding heap corruption in debug build
When I run my app, I am getting a message "Invalid address specified
to RtlValidateHeap / This may be due to a corruption of the heap...".
This is an MFC dialog-based static build, using VS2005/XP.
Using the debugger, I have isolated the error to the code in my app
mp_real sqrt2;
std::string s
s=sqrt2.to_string(50);
The error message comes from the destruction of the temporary string
returned by to_string; i e, when to_string returns, its result is in a
temporary string, which is copied to app's string s. The temporary
string provided by to_string is then destroyed.
'to_string' is a member function of the class mp_real, and its return
type is string.
string mp_real::to_string(...)
{
string s=...
return s;
}
This function is in a DLL, and I think the error message is occurring
because the DLL is linked to CRT and using its own heap. I have the
source and can build the DLL.
How should I do the build and link of the DLL and my app so a debug
version doesn't get this error? Also, I want to make sure that a
release build of the DLL will not have any similar problem? Can I use
a debug DLL with a release build of an app, or a release build of the
DLL with a debug build of an app?
TIA for any guidance.