捕获lambda中的向量数组:可能的GCC错误?

时间:2016-04-01 08:52:48

标签: c++ gcc vector lambda c++14

此程序无法使用 GCC 5.3 g++ -std=c++14)进行编译:

#include <vector>

int main()
{
    std::vector<int> v[] = {std::vector<int>(10), std::vector<int>(10)};

    auto lambda = [v]{};
}

报告错误:

file.cpp: In function ‘int main()’:
file.cpp:7:20: internal compiler error: in build_special_member_call, at cp/call.c:7789
  auto lambda = [v]{};
                    ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.

我尝试使用 clang 并成功编译(live example)。

这个程序是否形成良好?这可能是GCC的错误吗?

1 个答案:

答案 0 :(得分:2)

海湾合作委员会明确告诉你这是一个错误,你应该如何报道这个:

file.cpp: In function ‘int main()’:
file.cpp:7:20: internal compiler error: in build_special_member_call, at cp/call.c:7789
  auto lambda = [v]{};
                    ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.

我可以确认在香草GCC 5上发生了同样的错误,所以请在http://gcc.gnu.org/bugs.html处提出错误您可能还想提一下该错误发生在主干上(也已确认)。这是GCC 4.9的回归。