Internal compiler error with nvcc 11.3

(I’m not sure if this topic belongs in the CUDA Programming or Developer Tools forum, so it’s posted in both locations)

Hi, I’m in the process of migrating a C++ project over to CUDA and running into a few compiler issues along the way. One of them is related to using C++17 for CTAD with std::tuple in host code. A small reproducer is given below:

#include <tuple>
auto foo(int a, int b) { return std::tuple{a, b}; }
int main() { foo(3, 2); }

When compiling with the newest nvcc:

$ uname -r
5.8.0-50-generic (ubuntu 20.04)

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:15:46_PDT_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0

$ nvcc -std=c++17 
/usr/include/c++/9/tuple(580): internal error: assertion failed at: "il_to_str.c", line 1994 in form_type_specifier
1 catastrophic error detected in the compilation of "".
Compilation aborted.
Aborted (core dumped)

An older version of nvcc (11.1) doesn’t seem to have this issue:

$ path/to/old/cuda/bin/nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0
$ path/to/old/cuda/bin/nvcc -std=c++17

Furthermore, manually specifying the template arguments for std::tuple seems to address the issue as well:

#include <tuple>
auto foo(int a, int b) { return std::tuple<int,int>{a, b}; }
int main() { foo(3, 2); }
$ nvcc -std=c++17
$ path/to/old/cuda/bin/nvcc -std=c++17
$ (nvcc v11.1 and v11.3 both work!)

The documentation says to expect nvcc >= v11.0 to support C++17 language features (with a few exceptions seemingly unrelated to this issue).

Is this a known limitation, or a regression in the 11.3 version of nvcc?

1 Like

I suggest filing a bug. The instructions are linked to a sticky post at the top of this forum.