Valid code fails with "reference to local variable declared in enclosing function" · Issue #140632 · llvm/llvm-project (original) (raw)

#include #include

int main() { constexpr auto v = std::array{1, 2, 3, 4, 5, 6}; for (auto const& [t0, t1, t2] : v | std::views::adjacent<3>) { } }

error: reference to local variable 'v' declared in enclosing function 'main'

Works in GCC 15.1
Error in clang 20.1.0
Works if you remove constexpr

godbolt link