Parameter pack doesn't compile on NVHPC

The following program doesn’t compile with NVHPC:

bad.cpp

template <int A> struct S {};
template <int... Ts> void bad() {
  using F = void(*)(int);
  F data[] = {[](auto) { S<Ts>(); }...};
}

int main(){
    bad<1,2,3>();
    return 0;
}
> nvc++ -std=c++17 bad.cpp 
"bad.cpp", line 4: error: parameter pack "Ts" was referenced but not expanded
    F data[] = {[](auto) { S<Ts>(); }...};
                             ^

"bad.cpp", line 4: error: pack expansion does not make use of any argument packs
    F data[] = {[](auto) { S<Ts>(); }...};
                                     ^

"bad.cpp", line 4: error: expected a "}"
    F data[] = {[](auto) { S<Ts>(); }...};
                                     ^
          detected during instantiation of "void bad<Ts...>() [with Ts=<1, 2, 3>]" at line 8

"bad.cpp", line 4: warning: variable "data" was declared but never referenced
    F data[] = {[](auto) { S<Ts>(); }...};
      ^
          detected during instantiation of "void bad<Ts...>() [with Ts=<1, 2, 3>]" at line 8

3 errors detected in the compilation of "bad.cpp".

This compiles without any issues since GCC 8/Clang 6 or newer, Intel ICX 2021.3 also compiled fine.
The error is reproducible on both NVHPC 21.5 and 21.9.

If I swap out the auto in the lambda parameter with the concrete type (int in this case), then it compiles.

Thanks user2140. I’ve replicated the issue here and filed a problem report, TPR #30777.

-Mat

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.