VSCode cannot see <ranges> namespaces in Clang 15
Type: Bug
I have been playing around with Clang 15 on Linux. I installed it via: https://apt.llvm.org/ I created the "update-alternatives" manually, etc.
I copy & pasted this piece of code in a test CMake project:
std::cout << "Ranges\n";
auto const ints = { 0, 1, 2, 3, 4, 5 };
auto even = [](int i) { return 0 == i % 2; };
auto square = [](int i) { return i * i; };
// "pipe" syntax of composing the views:
for (int i :
ints | std::views::filter(even) | std::views::transform(square)) {
std::format("where am i? {}", "\n");
std::cout << i << ' ';
}
std::cout << '\n';
// a traditional "functional" composing syntax:
for (int i : std::views::transform(std::views::filter(ints, even), square))
{
std::cout << i << ' ';
}
std::cout << "\n";
With GCC 12 config:

With Clang 15 config:

Extension version: 1.12.4 VS Code version: Code 1.71.2 (74b1f979648cc44d385a2286793c226e611f59e7, 2022-09-14T21:12:14.256Z) OS version: Linux x64 5.15.0-47-generic snap Modes: Sandboxed: No
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800) |
| GPU Status | 2d_canvas: unavailable_software canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: disabled_software multiple_raster_threads: enabled_on opengl: disabled_off rasterization: disabled_software raw_draw: disabled_off_ok skia_renderer: enabled_on video_decode: disabled_software video_encode: disabled_software vulkan: disabled_off webgl: unavailable_software webgl2: unavailable_software webgpu: disabled_off |
| Load (avg) | 1, 1, 1 |
| Memory (System) | 7.42GB (3.47GB free) |
| Process Argv | --no-sandbox --force-user-env --unity-launch --crash-reporter-id 20280fc3-3c6d-43d3-9eb5-55c536b003d8 |
| Screen Reader | no |
| VM | 0% |
| DESKTOP_SESSION | ubuntu-wayland |
| XDG_CURRENT_DESKTOP | Unity |
| XDG_SESSION_DESKTOP | ubuntu-wayland |
| XDG_SESSION_TYPE | wayland |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30557514
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vscaat:30438848
vsclangdf:30486550
c4g48928:30535728
hb751961:30553087
dsvsc012cf:30540253
azure-dev_surveyone:30548225
2144e591:30553903
vsccc:30566497
fc301958:30567733
I'm not reproing the issue. Can you run C/C++: Log Diagnostics and provide the output and/or verify the clang 15 compiler is being used with C++23?
Also, you could run a command line /usr/bin/clang++-15 -std=c++2b -E ./test.cpp > ./test.out.cpp to generate a preprocessed file and look for an IntelliSense error that may be the root cause of the failure and what header is causing it.
This is 100% reproducible on my machine with the described setup with the attached Test.zip. Some details:
- x64 Ubuntu 22.04
- LLVM installed from here: https://apt.llvm.org/
- Ubuntu's GCC 12 package
Steps to reproduce:
- Start VSCode
- The project is opened by default, VSCode GCC Debug preset is selected by default.
- Switch to VSCode Clang Debug, rebuild
Observed the red squiggly lines. The squiggles appeared after the rebuild.

Please note the ranges include location:

I'm not reproing the issue. Can you run C/C++: Log Diagnostics and provide the output and/or verify the clang 15 compiler is being used with C++23?
This is the output:
-------- Diagnostics - 9/22/2022, 9:02:57 AM
Version: 1.12.4
Current Configuration:
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64",
"intelliSenseModeIsExplicit": false,
"cStandardIsExplicit": false,
"cppStandardIsExplicit": false,
"mergeConfigurations": false,
"compilerPathIsExplicit": false,
"configurationProvider": "ms-vscode.cmake-tools",
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
Custom browse configuration:
{
"browsePath": [
"/home/hristo/Projects/ClangTest/src"
],
"compilerPath": "/usr/bin/clang++",
"compilerArgs": [],
"compilerFragments": [
"-g",
"-stdlib=libc++",
"-fexperimental-library",
"-W",
"-Wall",
"-Werror",
"-Wpedantic",
"-std=gnu++2b"
]
}
Custom configurations:
[ /home/hristo/Projects/ClangTest/src/main.cpp ]
{
"includePath": [],
"defines": [],
"compilerPath": "/usr/bin/clang++",
"compilerArgs": [],
"compilerFragments": [
"-g",
"-stdlib=libc++",
"-fexperimental-library",
"-W",
"-Wall",
"-Werror",
"-Wpedantic",
"-std=gnu++2b"
]
}
Translation Unit Mappings:
[ /home/hristo/Projects/ClangTest/src/main.cpp ]:
/home/hristo/Projects/ClangTest/src/main.cpp
Translation Unit Configurations:
[ /home/hristo/Projects/ClangTest/src/main.cpp ]:
Process ID: 6330
Memory Usage: 124 MB
Compiler Path: /usr/bin/clang++
Includes:
/usr/lib/llvm-15/include/c++/v1
/usr/lib/llvm-15/lib/clang/15.0.1/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
Standard Version: c++23
IntelliSense Mode: linux-clang-x64
Other Flags:
--clang
--clang_version=150001
Total Memory Usage: 124 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 22051
/usr/bin/clang++-15 -std=c++2b -E ./test.cpp > ./test.out.cpp
I run this command: /usr/bin/clang++-15 -std=c++2b -E ./main.cpp > ./main.out.cpp but I don't think that it is correct. Here is the output anyway:
Also, you could run a command line
/usr/bin/clang++-15 -std=c++2b -E ./test.cpp > ./test.out.cppto generate a preprocessed file and look for an IntelliSense error that may be the root cause of the failure and what header is causing it.
Should the command be: /usr/bin/clang++-15 -std=c++2b -stdlib=libc++ -fexperimental-library -E ./main.cpp > ./main.out.cpp
$ update-alternatives --config gcc There is only one alternative in link group gcc (providing /usr/bin/gcc): /usr/bin/gcc-12 Nothing to configure. $ update-alternatives --config g++ There is only one alternative in link group g++ (providing /usr/bin/g++): /usr/bin/g++-12 Nothing to configure. $ update-alternatives --config clang There is only one alternative in link group clang (providing /usr/bin/clang): /usr/bin/clang-15 Nothing to configure. $ update-alternatives --config clang++ There is only one alternative in link group clang++ (providing /usr/bin/clang++): /usr/bin/clang++-15 Nothing to configure.
Clean reconfigure for *VSCode Clang Debug" CMake preset:
[main] Configuring folder: ClangTest [driver] Removing /home/hristo/Projects/ClangTest/.build/vscode-clang-debug/CMakeCache.txt [driver] Removing /home/hristo/Projects/ClangTest/.build/vscode-clang-debug/CMakeFiles [proc] Executing command: /snap/cmake/current/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/hristo/Projects/ClangTest/.build-out/vscode-clang-debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -S/home/hristo/Projects/ClangTest -B/home/hristo/Projects/ClangTest/.build/vscode-clang-debug -G Ninja [cmake] -- The CXX compiler identification is Clang 15.0.1 [cmake] -- Detecting CXX compiler ABI info [cmake] -- Detecting CXX compiler ABI info - done [cmake] -- Check for working CXX compiler: /usr/bin/clang++ - skipped [cmake] -- Detecting CXX compile features [cmake] -- Detecting CXX compile features - done [cmake] -- CPACK_GENERATOR: DEB;RPM [cmake] -- CPACK_DEBIAN_PACKAGE_NAME ClangTest [cmake] -- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA /home/hristo/Projects/ClangTest/assets/linux/package/deb/scripts/preinst [cmake] -- CPACK_PROJECT_NAME ClangTest [cmake] -- --- AFTER CPack --- [cmake] -- CPACK_GENERATOR: TBZ2;TGZ;TXZ;TZ [cmake] -- CPACK_DEBIAN_PACKAGE_NAME ClangTest [cmake] -- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA /home/hristo/Projects/ClangTest/assets/linux/package/deb/scripts/preinst [cmake] -- CPACK_PROJECT_NAME ClangTest [cmake] -- Configuring done [cmake] -- Generating done [cmake] CMake Warning: [cmake] Manually-specified variables were not used by the project: [cmake] [cmake] CMAKE_C_COMPILER [cmake] [cmake] [cmake] -- Build files have been written to: /home/hristo/Projects/ClangTest/.build/vscode-clang-debug
Clean reconfigure for VSCode GCC Debug CMake preset:
[main] Configuring folder: ClangTest [driver] Removing /home/hristo/Projects/ClangTest/.build/vscode-gcc-debug/CMakeCache.txt [driver] Removing /home/hristo/Projects/ClangTest/.build/vscode-gcc-debug/CMakeFiles [proc] Executing command: /snap/cmake/current/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/hristo/Projects/ClangTest/.build-out/vscode-gcc-debug -DCMAKE_C_COMPILER=/usr/bin/gcc-12 -DCMAKE_CXX_COMPILER=/usr/bin/g++-12 -S/home/hristo/Projects/ClangTest -B/home/hristo/Projects/ClangTest/.build/vscode-gcc-debug -G Ninja [cmake] -- The CXX compiler identification is GNU 12.1.0 [cmake] -- Detecting CXX compiler ABI info [cmake] -- Detecting CXX compiler ABI info - done [cmake] -- Check for working CXX compiler: /usr/bin/g++-12 - skipped [cmake] -- Detecting CXX compile features [cmake] -- Detecting CXX compile features - done [cmake] -- CPACK_GENERATOR: DEB;RPM [cmake] -- CPACK_DEBIAN_PACKAGE_NAME ClangTest [cmake] -- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA /home/hristo/Projects/ClangTest/assets/linux/package/deb/scripts/preinst [cmake] -- CPACK_PROJECT_NAME ClangTest [cmake] -- --- AFTER CPack --- [cmake] -- CPACK_GENERATOR: TBZ2;TGZ;TXZ;TZ [cmake] -- CPACK_DEBIAN_PACKAGE_NAME ClangTest [cmake] -- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA /home/hristo/Projects/ClangTest/assets/linux/package/deb/scripts/preinst [cmake] -- CPACK_PROJECT_NAME ClangTest [cmake] -- Configuring done [cmake] -- Generating done [cmake] CMake Warning: [cmake] Manually-specified variables were not used by the project: [cmake] [cmake] CMAKE_C_COMPILER [cmake] [cmake] [cmake] -- Build files have been written to: /home/hristo/Projects/ClangTest/.build/vscode-gcc-debug
With the main2.zip file I hit https://developercommunity.visualstudio.com/t/C-IntelliSense-doesnt-recognize-clang/10156062 , which might be the root cause of this bug, but I'm not sure yet. I don't get the error when I remove the __attribute__((using_if_exists)).
Also, with the main.zip, I'm getting some "not implemented" error internally -- our C++23 support is still in development so it looks like the system header code is using features we don't support yet. Are you able to repro the issue with C++20? I can try myself later too...
It's the same in C++20 mode. The squiggles appear/disappear only after a rebuild (after switching a cmake configure preset):

Ah, okay -- I got the repro now -- I didn't have libc++ installed. I'm investigating...
UPDATE: Looks like we aren't handling "-fexperimental-library" sufficiently -- clang itself gives the same error without that flag. Still investigating...
@Zingam You should be able to work around the issue via using "defines": [ "__has_feature(experimental_library)=1"], I'm not sure yet if the fix will make it into 1.13.1 or not.
Fixed with 1.13.1: https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.1
I switched to 1.13.1. I can confirm that the reported issue is fix.
Now I'm experiencing two more issues with the same "test".
- Performance when CTRL+Click on std::view is very poor on my machine. It takes very long to load the IntelliSense data, and then the line that should appears under std::range::view feels to no appear: appears disappears. This feature behaves erratically. This sluggish behavior is present in the Clang configuration. In the GCC configuration the performance is much smoother. IMO
- In the GCC configuration now I am seeing this (I haven't noticed this error before):
@Zingam Okay, I've filed https://github.com/microsoft/vscode-cpptools/issues/9937 to track those issues.