NVC++ 23.1 F-0000-Internal compiler error with std::function ref to lambda

Hello,

I think I found a bug in the nvc++ compiler. To give you some context, I’m trying to use the stl parallel algorithms with a std::function. It generates an internal error in the compiler. I tried to create a simple example that generates this issue.

Here is the error I get :

nvc++ -std=c++20 -stdpar=gpu -gpu=cuda12.0 -O4 test2.cpp  -o test2
NVC++-F-0000-Internal compiler error. cf_data_init: unknown datatype     -54  (test2.cpp)
NVC++/x86-64 Linux 23.1-0: compilation aborted

Here’s the code that produces this error :

/*
Issue small example
*/

#include <algorithm>
#include <execution>
#include <functional>
#include <vector>
constexpr size_t kSize = static_cast<size_t>(1.5e6);

int main() {
    std::vector<float> in_vect(kSize);
    std::vector<float> out_vect(kSize);
    for (int i = 0; i < kSize; i++) {
        in_vect[i] = static_cast<float>(std::rand() - RAND_MAX / 2);
    }

    std::function<float(float)> multiply_by_two = [](float f) { return 2.0F * f; };
    std::transform(std::execution::par, in_vect.begin(), in_vect.end(), out_vect.begin(), multiply_by_two);
    return 0;
}

Configuration :

edit: This piece of code compiles and works with gcc 12.1.0 and 11.3.0

g++ -std=c++20 test2.cpp -ltbb -O3 -o test2 && ./test2

Thanks for the report michael.el-kharroubi.

I was able to reproduce the error here but only when using the GNU 11.3 or 12.x STL. For GNU 11.2 or earlier, I’m seeing a different error, an undefined reference.

Hence I added two problem reports. TPR #33214 for the ICE and #33215 for the undefined reference.

-Mat

1 Like