相关疑难解决方法(0)

为什么clang ++只会破坏一个foo对象?

我有以下示例代码:

#include <iostream>
using namespace std;

struct foo {
    foo()  { cout << "foo constructed.\n"; }
    ~foo() { cout << "foo destroyed.\n"; }
};

struct bar {
    bar(foo t=foo{}) { }
};

int main(int argc, char **argv) {
    bar X[2]{};
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我用clang ++ -std = c ++ 11 test.cc编译它时,程序产生以下输出:

foo constructed.
foo constructed.
foo destroyed.
Run Code Online (Sandbox Code Playgroud)

但我预计还有一个"foo被摧毁".介于两个"foo构造"之间.线.为什么只有一个foo被摧毁?clang 3.5.1以及3.6.0会发生这种情况.

c++ clang

51
推荐指数
1
解决办法
748
查看次数

(已知)VC12中的编译器错误?

当使用VC12(在Visual Studio 2013 RTM中)[1]编译时,此程序会导致崩溃(在所有构建配置中),而实际上它不应该:

#include <string>

void foo(std::string const& oops = {})
{
}

int main()
{
    foo();
}
Run Code Online (Sandbox Code Playgroud)

我知道两个可能有关的无声的错误代码错误:

老实说,我认为这些是不同的.有人知道吗

  1. 是否存在关于连接的主动跟踪错误
  2. 是否有解决方法(或导致此错误的情况的明确描述,所以我们可以在我们的代码库中查找/避免它)?

[1]使用C++ Console Application'向导'创建一个空项目.为简单起见,请禁用预编译标头并保留所有默认值:http://i.stack.imgur.com/rrrnV.png

c++ visual-c++ compiler-bug visual-studio-2013

26
推荐指数
2
解决办法
2961
查看次数