zig
zig copied to clipboard
zig c++: Fails to find std::views::chunk from <ranges> with -std=c++23
Zig Version
0.15.2
Steps to Reproduce and Observed Behavior
$ echo -e "#include <ranges>\nauto ints = {0,1,2,3}; auto tmp = ints | std::views::chunk(2);" > chunk.cpp
$ g++ chunk.cpp -std=c++23 -c # No error
$ clang++ chunk.cpp -std=c++23 -c # No error
$ zig c++ chunk.cpp -std=c++23 -c
chunk.cpp:2:54: error: no member named 'chunk' in namespace 'std::ranges::views'
2 | auto ints = {0,1,2,3}; auto tmp = ints | std::views::chunk(2);
| ~~~~~~~~~~~~^
1 error generated.
Expected Behavior
The file should compile
Which Clang version are you testing with?
clang --version
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
I run all the commands in docker.io/nvidia/cuda:13.0.1-cudnn-devel-ubuntu24.04 container.
just looks like a libc++ issue
~ $ clang++ -v
clang version 21.1.0 (https://github.com/llvm/llvm-project 3623fe661ae35c6c80ac221f14d85be76aa870f1)
~ $ clang++ chunk.cpp -std=c++23 -c -stdlib=libstdc++
~ $ clang++ chunk.cpp -std=c++23 -c -stdlib=libc++
chunk.cpp:2:54: error: no member named 'chunk' in namespace 'std::ranges::views'
2 | auto ints = {0,1,2,3}; auto tmp = ints | std::views::chunk(2);
| ^~~~~
1 error generated.
Is there any workaround, I tried zig c++ with -stdlib=libstdc++ but it does not work.
$ zig c++ chunk.cpp -std=c++23 -c -stdlib=libc++
zig: warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]
chunk.cpp:2:54: error: no member named 'chunk' in namespace 'std::ranges::views'
2 | auto ints = {0,1,2,3}; auto tmp = ints | std::views::chunk(2);
| ~~~~~~~~~~~~^
1 error generated.
There is an upstream issue about implementing views::chunk
https://github.com/llvm/llvm-project/issues/105187