Kon*_*zin 7 c++ visual-c++-2008 visual-c++ visual-c++-2005
在VS2005 SP1的Debug配置中编译的以下代码显示了两条带有"ITERATOR LIST CORRUPTED"通知的消息.
代码片段
#define _SECURE_SCL 0
#define _HAS_ITERATOR_DEBUGGING 0
#include <sstream>
#include <string>
int main()
{
std::stringstream stream;
stream << "123" << std::endl;
std::string str = stream.str();
std::string::const_iterator itFirst = str.begin();
int position = str.find('2');
std::string::const_iterator itSecond = itFirst + position;
std::string tempStr(itFirst,itSecond); ///< errors are here
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是编译器或标准库中的错误吗?
@dirkgently 在他的编辑中说了什么。
显然,有些代码std::string
位于运行时dll中,特别是宏定义对构造函数不生效,而迭代器调试的代码被执行。您可以通过静态链接运行时库来解决此问题。
我认为这是一个错误,尽管可能不是在 Visual Studio 本身中,而是在文档中。