【问题标题】:Visual C++ compiler bug?Visual C++ 编译器错误?
【发布时间】:2020-08-26 16:04:34
【问题描述】:

我在下面尽可能地减少了我的情况。

#include <vector>
#include <atomic>
#include <chrono>

using namespace std;

class Unused
{
  private:

    vector<vector<unsigned>> data;
    atomic<unsigned> counter;
};

class Timer
{
  private:

    chrono::time_point<chrono::high_resolution_clock> begin;

  public:

    void start()
    {
      begin = std::chrono::high_resolution_clock::now();
    }

};

int main()
{
  Unused unused;

  vector<Timer> timers;
  timers.resize(1);
  timers[0].start();
}

我已将其编译为(注意具体标志):

cl /O2 /GL /EHsc driver.cpp

这是与

Microsoft (R) C/C++-Optimierungscompiler Version 19.27.29111 für x86
Microsoft (R) Incremental Linker Version 14.27.29111.0

但我也尝试了其他几个最新版本。可执行的段错误与内存访问冲突。它适用于 g++,如果我更改编译标志,它就可以工作。如果我进一步简化代码,它也可以工作。

这是编译器错误吗?

【问题讨论】:

    标签: visual-c++ compiler-bug


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2019-11-16
    • 2010-10-09
    • 2011-09-28
    • 1970-01-01
    • 1970-01-01
    • 2010-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多