C++ 模板和openmp崩溃导致异常重载解析失败
在我看来,在模板函数中使用omp collapse时,clang有一些问题 我附上了一个最小的例子。Clang(9,10,11)不能编译它,而gcc编译得很好。这是编译器错误还是我的代码做了非法的事情? 将此函数设为非模板或删除collapse子句使其可以正常编译C++ 模板和openmp崩溃导致异常重载解析失败,c++,templates,clang,openmp,C++,Templates,Clang,Openmp,在我看来,在模板函数中使用omp collapse时,clang有一些问题 我附上了一个最小的例子。Clang(9,10,11)不能编译它,而gcc编译得很好。这是编译器错误还是我的代码做了非法的事情? 将此函数设为非模板或删除collapse子句使其可以正常编译 #include <vector> #include <iostream> template <typename T> void test(const std::vector<int>
#include <vector>
#include <iostream>
template <typename T>
void test(const std::vector<int> begin_vec) {
#pragma omp parallel for collapse(2)
for (int n = begin_vec.at(0); n < 0; n++) {
for (int h = begin_vec.at(1); h < 1; h++) {
for (int w = begin_vec.at(2); w < 2; w++) {
std::cout << n + h + w << std::endl;
}}}
}
int main() {
test<int>({0,0,0});
}
(我也尝试过使用libc++,但它没有改变任何东西)似乎是个bug<代码>[]工作正常。感谢您的复制机,我们会检查并修复它。如果可能,最好将此类问题报告给。应通过提交8F51DC496973C494CC1D118979B59628E938AF13在clang trunk中修复此问题
test.cpp:9:16: error: 'this' argument to member function 'at' has type 'const std::vector<int>', but function is not marked const
for (int h = begin_vec.at(1); h < 1; h++) {
^~~~~~~~~
test.cpp:16:3: note: in instantiation of function template specialization 'test<int>' requested here
test<int>({0,0,0});
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:1092:7: note: 'at' declared here
at(size_type __n)
^