microsoft / microsoft/vscode-cpptools

IntelliSense wrongly underlined error if Explicit Object Parameter, Type Conversion Operator, and Template are used together.

Open
#13,061 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Windows_NT x64 10.0.19045
  • VS Code Version: 1.96.0
  • C/C++ Extension Version: 1.22.11, updated at 2024-11-06, 19:45:17
  • If using SSH remote, specify OS of remote machine: none
Bug Summary and Steps to Reproduce

Bug Summary:
IntelliSense error if Explicit Object Parameter, Type Conversion Operator, and Template are used together.

Steps to reproduce:

  1. create a new file named 'bug.cpp' (use cppStandard c++23).
  2. copy the code below into it:
struct A
{
    template <typename T>
    operator int(this T & self) { return 1; }
    operator char(this auto &self) { return 2; }
};

int main()
{
    A a;
    int i = a;
    int j = int(a);
    char k = char(a);
    return i;
}
  1. some codes are red underlined.

Expected behavior:
there should be no red underlined code.

Configuration and Logs
-------- Diagnostics - 2024/12/15 22:08:22
Version: 1.22.11
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.26100.0",
    "compilerPath": "cl.exe",
    "cStandard": "c17",
    "intelliSenseMode": "windows-msvc-x64",
    "compilerPathInCppPropertiesJson": "cl.exe",
    "cppStandard": "c++23",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": true,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.inlayHints.autoDeclarationTypes.enabled": true,
    "C_Cpp.inlayHints.parameterNames.enabled": true,
    "C_Cpp.default.cppStandard": "c++23"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.vt": "verilog",
        "*.ixx": "cpp",
        "*.asm": "masm"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": true,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.22.11.0
Current database path: C:\USERS\BIONUKG\APPDATA\LOCAL\TEMP\{0034E163-EF00-48B0-8732-7DB74FF7DE52}\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Users\bionukg\Desktop\bug\bug.cpp - source TU]:
Translation Unit Configurations:
[ C:\Users\bionukg\Desktop\bug\bug.cpp ]
    Process ID: 15812
    Memory Usage: 51 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64\cl.exe
    Includes:
    System Includes:
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\atlmfc\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\cppwinrt
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c++latest
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 51 MB
Other Extensions

No response

Additional context

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report in bug.cpp using C++23 and the supplied IntelliSense configuration, then inspect the diagnostics for the explicit object parameter, conversion operators, and template combination. Done means the valid example produces no red underlines; the payload names no source files or existing tests, so locating the relevant IntelliSense code and regression-test location will require project research.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.