zer*_*s00 1 c++ bug-tracking vector stdvector
我尝试使用Visual Studio 2012 RC和英特尔C++编译器XE 12.1进行编译.如果您尝试使用其他编译器,我将不胜感激.在代码中查看我的评论,真正体会到这个bug的奇怪之处.有谁知道发生了什么,我应该在哪里提交有关此问题的错误报告?
// File: NamedSameA.h
#pragma once
Run Code Online (Sandbox Code Playgroud)
// File: NamedSameA.cpp
#include <vector>
#include "NamedSameA.h"
struct NamedSame // Rename this class to something else to make the program work
{
std::vector<int> data;
// Comment out the previous line or change
// the data type to int to make the program work
};
static NamedSame g_data; // Comment out this line to make the program work
Run Code Online (Sandbox Code Playgroud)
// File: NamedSameB.h
#pragma once
void test();
Run Code Online (Sandbox Code Playgroud)
// File: NamedSameB.cpp
#include <vector>
#include "NamedSameA.h"
#include "NamedSameB.h"
struct NamedSame
{
int data1; // Comment out this line to make the program work
std::vector<int> data2;
};
void test()
{
NamedSame namedSame;
namedSame.data2.assign(100, 42);
// The previous line produces the following runtime error:
// -------------------------------------------------------
// Debug Assertion Failed!
// Program: C:\Windows\system32\MSVCP110D.dll
// File: c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector
// Line: 240
// Expression: vector iterators incompatible
}
Run Code Online (Sandbox Code Playgroud)