Issue 140632
Summary Valid code fails with "reference to local variable declared in enclosing function"
Labels new issue
Assignees
Reporter Ignition
    ```cpp
#include <array>
#include <ranges>

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](https://godbolt.org/z/7d3aW5Y4b)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to