Skip to content

Extension reports error for valid C++23 escape sequence #13338

@ebouteillon

Description

@ebouteillon

Environment

  • OS and Version: Windows 11 + WSL2 Ubuntu + RHEL-8 docker
  • VS Code Version: 1.97.2
  • C/C++ Extension Version: 1.24.1
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary:

C++ 23 introduced new escape sequences. See details in https://en.cppreference.com/w/cpp/language/escape .
Both GCC and clang support it (didn't tried with MSVC). However the extension "ms-vscode.cpptools" reports an error when present in code.

Steps to reproduce:

#include <array>
#include <iostream>

int main()
{
    const std::array<char, 2> x{"\x{3F}"};
    std::cout << "Hello \x{40}" << x[0] << std::endl;  // At runtime displays "Hello @?"
    return 0;
}

Above C++ code compiles fine, but these 2 errors are reported:

  • a value of type "const char [5]" cannot be used to initialize an entity of type "std::__array_traits<char, 2UL>::_Type" (aka "char [2]") C/C++(144)
  • invalid hexadecimal number C/C++(22)

Expected behavior:

No error reported when using C++23 escape sequence.

Configuration and Logs

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "cStandard": "c11",
            "cppStandard": "c++23",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}


-------- Diagnostics - 3/4/2025, 1:59:29 PM
Version: 1.24.1
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/axis/workspace/map-core/**"
    ],
    "defines": [],
    "cStandard": "c11",
    "cppStandard": "c++20",
    "intelliSenseMode": "linux-gcc-x64",
    "configurationProvider": "ms-vscode.cmake-tools",
    "compileCommands": [
        "/home/axis/workspace/map-core/build/compile_commands.json"
    ],
    "compilerPathIsExplicit": false,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compileCommandsInCppPropertiesJson": [
        "${workspaceFolder}/build/compile_commands.json"
    ],
    "configurationProviderInCppPropertiesJson": "ms-vscode.cmake-tools",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/home/axis/workspace/map-core/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.cppStandard": "c++23",
    "C_Cpp.codeAnalysis.exclude": {
        "**/.git": true,
        "**/build": true
    },
    "C_Cpp.codeAnalysis.clangTidy.enabled": true
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "any": "cpp",
        "array": "cpp",
        "atomic": "cpp",
        "bit": "cpp",
        "*.tcc": "cpp",
        "bitset": "cpp",
        "cctype": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "compare": "cpp",
        "concepts": "cpp",
        "condition_variable": "cpp",
        "cstdarg": "cpp",
        "cstddef": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "deque": "cpp",
        "list": "cpp",
        "map": "cpp",
        "set": "cpp",
        "string": "cpp",
        "unordered_map": "cpp",
        "unordered_set": "cpp",
        "vector": "cpp",
        "exception": "cpp",
        "algorithm": "cpp",
        "functional": "cpp",
        "iterator": "cpp",
        "memory": "cpp",
        "memory_resource": "cpp",
        "numeric": "cpp",
        "optional": "cpp",
        "random": "cpp",
        "ratio": "cpp",
        "regex": "cpp",
        "source_location": "cpp",
        "string_view": "cpp",
        "system_error": "cpp",
        "tuple": "cpp",
        "type_traits": "cpp",
        "utility": "cpp",
        "fstream": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "iosfwd": "cpp",
        "iostream": "cpp",
        "istream": "cpp",
        "limits": "cpp",
        "mutex": "cpp",
        "new": "cpp",
        "numbers": "cpp",
        "ostream": "cpp",
        "ranges": "cpp",
        "semaphore": "cpp",
        "span": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "stop_token": "cpp",
        "streambuf": "cpp",
        "thread": "cpp",
        "cinttypes": "cpp",
        "typeinfo": "cpp",
        "variant": "cpp",
        "*.k5": "cpp",
        "*.inc": "cpp",
        "*.def": "cpp",
        "chrono": "cpp",
        "*.k4": "cpp",
        "*.k5-64": "cpp",
        "cassert": "cpp",
        "cerrno": "cpp",
        "cfloat": "cpp",
        "climits": "cpp",
        "ios": "cpp",
        "locale": "cpp",
        "queue": "cpp",
        "stack": "cpp",
        "*.k4-64": "cpp",
        "charconv": "cpp",
        "codecvt": "cpp",
        "forward_list": "cpp",
        "format": "cpp"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true,
        "**/.trunk/*actions/": true,
        "**/.trunk/*logs/": true,
        "**/.trunk/*notifications/": true,
        "**/.trunk/*out/": true,
        "**/.trunk/*plugins/": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
Custom browse configuration: 
{
    "browsePath": [
        "/home/axis/workspace/map-core/build/CMakeFiles",
        "...snip..."
    ],
    "compilerPath": "/opt/rh/gcc-toolset-13/root/usr/bin/g++",
    "compilerArgs": [],
    "compilerFragments": [
        " -DUNIX -DLINUX -DGEN_GNU -D__STDC_CONSTANT_MACROS   -DDEBUG  -g -Og -Wall -W -Wwrite-strings -Wno-error -pipe  -std=gnu++23   -include /home/axis/workspace/map-core/libs/common/include/common/map_clang_analyzer.hpp",
        "-Wall",
        "-Wextra",
        "-pedantic",
        "-Werror",
        "-Wnon-virtual-dtor",
        "-Wformat=2",
        "-O0",
        "-fno-inline-small-functions",
        "-fno-omit-frame-pointer",
        "-ggdb3",
        "-fsanitize=address",
        "-fsanitize=undefined",
        "-fno-sanitize=vptr"
    ]
}
cpptools version (native): 1.24.1.0
Current database path: /home/axis/.cache/vscode-cpptools/da81b6228513e761d502224d12d89059/.browse.VC.db
Translation Unit Mappings:
[ /home/axis/workspace/map-core/testu/tpvtestu/src/tpv_init_testu.cpp - source TU]:
Translation Unit Configurations:
[ /home/axis/workspace/map-core/testu/tpvtestu/src/tpv_init_testu.cpp ]
    Process ID: 8544
    Memory Usage: 713 MB
    Compiler Path: /opt/rh/gcc-toolset-13/root/usr/bin/g++
    Includes:
        ...snip...
    System Includes:
        /opt/rh/gcc-toolset-13/root/usr/include/c++/13
        /opt/rh/gcc-toolset-13/root/usr/include/c++/13/x86_64-redhat-linux
        /opt/rh/gcc-toolset-13/root/usr/include/c++/13/backward
        /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/include
        /usr/local/include
        /opt/rh/gcc-toolset-13/root/usr/include
        /usr/include
    Defines:
        AXIS_ENABLE_CPP11
        AXIS_ENABLE_CPP14
        AXIS_ENABLE_CPP17
        AXIS_ENABLE_CPP20
        AXIS_ENABLE_CPP23
        MAP_OUTPUT_FOLDER="/tmp"
        PROTOBUF_USE_DLLS
        RAPIDJSON_HAS_STDSTRING=1
        RHEL_VERSION_NUMBER=8
        UNIX
        LINUX
        GEN_GNU
        __STDC_CONSTANT_MACROS
        DEBUG
    Forced Includes:
        /home/axis/workspace/map-core/libs/common/include/common/map_clang_analyzer.hpp
    Standard Version: c++23
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=130301
Total Memory Usage: 713 MB
Browse Paths from compile_commands.json, from workspace folder: /home/axis/workspace/map-core
    ...snip...

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 14594
Number of files parsed: 2

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions