#813·taskflow

v4.1.0 fails with NVCC 12.6 in IndexRanges::size()

Author: bwehlinCreated Sep 27, 2026Updated Sep 28, 2026
Labelsbug

Disclaimer: this issue was filed with the help of Codex, but it is a real issue that I hit while trying to compile with v4.1.0. The issue occurred within the stablebear (https://github.com/kthtda/stablebear) devcontainer if this helps with reproducing the issue.

I do not have the issue on commit 718b336.

Summary

Taskflow v4.1.0 fails to compile with NVCC 12.6.85 and GCC 13.4.0 on Ubuntu 22.04.5. Including taskflow/utility/iterator.hpp alone triggers the error; no tasks, kernels, or template instantiations are needed. The same file compiles with GCC directly.

The 4.1.0 release notes list CUDA 12.0 or newer as supported.

Taskflow reproducer

bash
git clone --depth 1 --branch v4.1.0 https://github.com/taskflow/taskflow.git

Save as repro.cu:

cpp
#include <taskflow/utility/iterator.hpp>
bash
nvcc -std=c++20 -Itaskflow -c repro.cu -o repro.o

Fails with:

taskflow/utility/iterator.hpp:706:29: error: default argument for template parameter for class enclosing ‘size_t tf::IndexRanges<T, N>::size() const’
  706 | size_t IndexRanges<T, N>::size() const {
      |                             ^~~~~

The GCC control succeeds:

bash
g++ -std=c++20 -x c++ -Itaskflow -c repro.cu -o repro-gcc.o

Reduced compiler reproducer (no Taskflow dependency)

Save as reduced.cu:

cpp
template <typename T, int N = 1>
struct Range {
  int size() const;
};

template <typename T, int N>
int Range<T, N>::size() const {
  auto value = []<int D>() { return D; };
  return value.template operator()<N>();
}
bash
g++ -std=c++20 -x c++ -c reduced.cu -o reduced-gcc.o  # succeeds
nvcc -std=c++20 -c reduced.cu -o reduced-nvcc.o       # fails

This appears to be an NVCC host-code generation bug. With --keep, the generated reduced.cudafe1.cpp incorrectly repeats N = 1 on the out-of-class member definition, although the source definition has no default:

cpp
template<class T, int N = 1>
int Range<T, N>::size() const { /* ... */ }

Workaround checked

Replacing the recursive templated lambda inside IndexRanges::size() with an equivalent loop allows compilation with NVCC 12.6.