OS: Windows 7 Pro
IDE: Visual Studio 2015
Dear folks,
I have a strange thing happening when I try to run any application compiled with standard debug settings and linked to the debug version of Apache log4cxx, a logger DLL that I also compiled with its standard debug settings.
When I run the code as below, with
LOG4CXX_INFO(logger0, st.c_str());
then it writes "xyz" to the console, as to be expected.
However, when I run it with
LOG4CXX_INFO(logger0, st);
i.e. the string object being handed to the dll function (by reference), the program crashes. Stepping into the function that is called reveals, that the buffer of the string object () does not point to the same address (0x0037fa58 "xyz") but to (0x0037fa54 "xyz"), i.e. 4 bytes to the left of the original.
Any hint is greatly appreciated - thank you so much.
Cheers
Werner
Calling Code
std::string st = std::string("xyz");
LOG4CXX_INFO(logger0, st);
Code called
CharMessageBuffer& MessageBuffer::operator<<(const std::string& msg) {
return cbuf.operator<<(msg);
}
What I have tried:
I suspected _ITERATOR_DEBUG_LEVEL and checked, whether it was 2 in both app and dll (true). If I set _ITERATOR_DEBUG_LEVEL=0, surprisingly, the app also links to the dll without complain and the string reference is handed properly to the called function: The code works.