Skip to content

Deducing this (Explicit object member functions) not supported for conversion operators #14140

@lukas-lang

Description

@lukas-lang

Environment

  • OS and Version: Windows 11, 25H2
  • VS Code Version: 1.108.1
  • C/C++ Extension Version: 1.29.3
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary:
Deducing this is not supported for conversion operators, and instead results in a series of errors being reported

Steps to reproduce:

  1. Set the C++ version to C++23
  2. Create a file with the following content:
    auto ftm = __cpp_explicit_this_parameter;
    
    struct foo
    {
        auto bar(this auto &&self)
        {
            return 1;
        }
    
        operator int(this auto &&self)
        {
            return 1;
        }
    };
    
    int main()
    {
        int bar = foo{};
        
        return foo{}.bar();
    }
    
  3. Observe the errors in the problems panel
    Expected behavior: No errors
    Observed behavior: There are 3 errors reported
an operator name must be declared as a function C/C++(501)
expected a ';' C/C++(65)
no suitable conversion function from "foo" to "int" exists C/C++(413)

Configuration and Logs

## Settings
`"C_Cpp.default.cppStandard": "c++23"`
## C/C++: Log Diagnostics
-------- Diagnostics - 1/19/2026, 10:59:49 AM
Version: 1.29.3
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "compilerPath": "cl.exe",
    "cStandard": "c17",
    "intelliSenseMode": "windows-msvc-x64",
    "compilerPathInCppPropertiesJson": "cl.exe",
    "cppStandard": "c++23",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": true,
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.cppStandard": "c++23",
    "C_Cpp.loggingLevel": "Debug"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": false,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.bsh": "java",
        "*.m": "matlab",
        "*.tr": "wolfram"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.29.2.0
Current database path: C:\USERS\LUKAS\APPDATA\LOCAL\TEMP\{117CBE87-EFA1-445B-BCF0-1BA778E337A1}\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Users\Lukas\Downloads\test.cpp - source TU]:
Translation Unit Configurations:
[ C:\Users\Lukas\Downloads\test.cpp ]
    Process ID: 5212
    Memory Usage: 59 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\bin\Hostx64\x64\cl.exe
    Include paths:
        system include: C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c++23
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 59 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 263

Other Extensions

Note that MSVC 17.2 and later has no problem with the code (when removing the feature test macro): https://godbolt.org/z/qvMcbGd3b

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceVisual StudioInherited from Visual StudiobugfixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions