#24232·cudf

[BUG] Missing #include <variant> in cudf/ast/expressions.hpp breaks build with GCC 16

Author: karthikeyannCreated Sep 18, 2026Updated Sep 18, 2026

Describe the bug

cpp/include/cudf/ast/expressions.hpp uses std::variant, std::visit, std::holds_alternative and std::get_if but does not include <variant>. It currently compiles because <variant> is pulled in transitively by another libstdc++ header; GCC 16's libstdc++ no longer provides it transitively, so the header fails to parse.

This is the usual missing-include breakage that surfaces on each GCC major bump (same class as the earlier <cstdint> churn).

Because expressions.hpp fails to parse, the errors cascade widely — a single missing include produced 62 errors across the ast sources in our build, including misleading follow-on diagnostics such as:

error: "scalar" is not a nonstatic data member or base class of class "cudf::ast::literal"
error: exception specification for implicitly declared virtual function
       "cudf::ast::literal::~literal" is incompatible with that of overridden function

The root diagnostics are:

error: namespace "std" has no member "visit"
error: namespace "std" has no member "holds_alternative"
error: namespace "std" has no member "get_if"

Steps/Code to reproduce bug

Build libcudf with GCC 16 as the host compiler:

nvcc -ccbin=/opt/rh/gcc-toolset-16/root/usr/bin/g++ -std=c++20 ...

Any TU that includes cudf/ast/expressions.hpp fails. Failing objects in our build included:

src/ast/expressions.cpp.o
src/ast/expression_parser.cpp.o
src/ast/operators.cpp.o
src/ast/jit/expressions.cpp.o

Expected behavior

The header includes the standard headers it uses, so it compiles independently of what other libstdc++ headers happen to pull in.

Suggested fix

Add the include alongside the existing standard includes:

diff
 #include <cstdint>
+#include <variant>
 #include <functional>

I verified this locally: adding #include <variant> clears all 62 errors.

Environment details

  • cuDF: commit 456580fcdd726380dcb3de6b9686e7d47d6dd0a2 (release/26.10)
  • Compiler: GCC 16.2.1 20260807 (Red Hat 16.2.1-1, gcc-toolset-16)
  • CUDA: 13.4 (nvcc V13.4.92)
  • OS: CentOS Stream 9
  • Standard: -std=gnu++20
  • Consumer: Velox (VELOX_ENABLE_CUDF=ON), which builds libcudf from source via CPM

Note: GCC 16 requires CUDA >= 13, since CUDA 12.x nvcc hard-rejects GCC > 14.

Additional context

Found while evaluating GCC 16 support for Velox's cuDF backend. A second, unrelated GCC 16 issue in cuDF is filed separately (ambiguous union_member::get overloads in typed_statistics_chunk.cuh).

The same missing-<variant> problem also exists in rtcx (include/rtcx/embed.hpp), which is a separate repository.