Skip to content

IntelliSense flags C++23 features (e.g., import std;, std::println) as errors with GCC 15.1; C++ standard options outdated #13645

Open
@Blinkion

Description

@Blinkion

Environment

  • OS and Version: Ubuntu 24.04 LTS
  • VS Code Version: 1.100.2
  • C/C++ Extension Version: 2.0.0
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Detailed Description:

The VS Code C/C++ extension's IntelliSense (provided by ms-vscode.cpptools) incorrectly reports errors for valid C++23 features, such as import std; and std::println(). This occurs when using GCC 15.1, a compiler that successfully compiles and runs this code with the appropriate C++23 flags (-std=c++23 -fmodules).

A key observation from the attached screenshot (which you should attach to the issue) is that while the code editor shows red squiggles under these C++23 constructs, the terminal output clearly shows successful compilation and execution of the same code.

Furthermore, the C++ standard selection in VS Code settings (e.g., C_Cpp.default.cppStandard or per-project c_cpp_properties.json) does not currently offer a "c++26" option. While C++26 is still under development, the existing "c++23" IntelliSense support appears to be lagging behind features already implemented and available in modern compilers like GCC 15.1.

Expected Behavior:

IntelliSense should accurately parse and recognize standard C++23 features like modules (import std;) and std::println without showing false positive errors when a compatible compiler (like GCC 15.1) is used and the cppStandard is configured to c++23.
The C++ standard selection options in VS Code's C/C++ extension settings should be updated more frequently to include newer standards (e.g., "c++26", even if initially experimental) to better align with ongoing C++ language evolution and compiler support.
The existing c++23 IntelliSense mode should offer comprehensive coverage for features widely supported by major compilers.
Compiler Information (from screenshot):

Compiler: GCC
Version: 15.1.0
Target: x86_64-pc-linux-gnu
Configuration Snippet from gcc -v: Configured with: ../../gcc-15-source/configure --prefix=/opt/gcc-15 --disable-multilib --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
Steps to Reproduce:

Setup Environment:
Install GCC 15.1.0 (or a similarly capable C++23 compiler).
Ensure VS Code and the ms-vscode.cpptools C/C++ extension are installed and up to date.
Create Project & Configure:
Create a new C++ file (e.g., main.cc).
Populate main.cc with the following C++23 code:
C++

import std;

auto main() -> int {
std::println("Hello world");
return 0;
}
Configure the C/C++ extension settings (c_cpp_properties.json) to use cppStandard: "c++23" and point compilerPath to your GCC 15.1 g++. You might also need to add relevant compilerArgs like -fmodules or -fmodules-ts if IntelliSense requires them, though GCC 15.1 might handle module paths automatically for import std; when built correctly. Example c_cpp_properties.json configuration:
JSON

{
"configurations": [
{
"name": "Linux-GCC15",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/opt/gcc-15/bin/g++", // Adjust to your GCC 15.1 path
"cStandard": "c17",
"cppStandard": "c++23",
"intelliSenseMode": "linux-gcc-x64", // Or the mode corresponding to your GCC version
"compilerArgs": [
"-fmodules" // As seen working in your screenshot for compilation
]
}
],
"version": 4
}
Observe IntelliSense Errors:
Open main.cc in the VS Code editor.
Notice that IntelliSense incorrectly underlines import std; and std::println("Hello world"); as errors (e.g., "identifier "std" is undefined", "name followed by '::' must be a class or namespace name", "namespace "std" has no member "println"").
Verify Compilation (Outside VS Code or via Tasks):
Compile the code from the terminal using GCC 15.1 to confirm it's valid:
Bash

If you have a precompiled std module (e.g., bits/std.cc.gcm)

g++ -std=c++23 -fmodules -O2 -c -fmodule-only -fsearch-include-path bits/std.cc

(This step might not be needed if GCC finds the std module automatically)

g++ -std=c++23 -fmodules -O2 main.cc -o main
./main
Observe that the code compiles and runs successfully, printing "Hello world" (as shown in your screenshot).

Image

Configuration and Logs

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/c++/13",
                "/usr/include/x86_64-linux-gnu/c++/13",
                "/usr/include/c++/13/backward",
                "/usr/local/include",
                "/usr/include",
                "/usr/include/x86_64-linux-gnu"
            ],
            "defines": [],
            "intelliSenseMode": "linux-gcc-x64",
            "cStandard": "c23",
            "cppStandard": "c++23",
            "compilerPath": "/usr/bin/gcc"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions