问题描述
对于 MS Visual Studio 2019 中的调试版本,Ver. 16.10.0,工具集 v142, 我得到了下面的代码异常: _Orphan_range_unlocked() 中的“读取访问冲突” (可能与此处讨论的内容非常相似 [1])
在较旧的 VS 版本、发布版本或使用 clang 工具集时不会出现此问题。 但是,由于崩溃只发生在这些非常特殊的情况下,我怀疑 Visual Studio 中可能存在错误。还是毕竟是编程错误? 我想了解这一点。
#include <vector>
#include <array>
int main()
{
// Exception: 'read access violation' in _Orphan_range_unlocked()
// (in C++20 MSVC Debug builds but not in C++17 nor Release)
static std::array<std::vector<int>,4> arrvec;
arrvec[0].reserve(3);
arrvec[0].emplace_back(1); // <- Exception occurs here
}
[1]:https://stackoverflow.com/a/62605686/15157143)
为此,我在这里打开了一个错误报告:https://github.com/microsoft/STL/issues/1934
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)