Skip to content

Concept always fails when it has lambda inside it #14160

@somedeveloper00

Description

@somedeveloper00

Environment

  • OS and Version: Windows 11 Dev Channel
  • VS Code Version: 1.109.~
  • C/C++ Extension Version: 1.30.3
  • If using SSH remote, specify OS of remote machine: ``

Bug Summary and Steps to Reproduce

Bug Summary:
If a concept has lambda, it'll always fail. For example

template <typename T>
concept HasField = requires { []() { return int(1); }(); };

will fail even though its valid in C++23 and should pass. I tried all the possible scenarios I could think of, and indeed its the lambda that causes this bug. Even an empty lambda will fail:

template <typename T>
concept HasField = requires { [](){}(); };

Note that this is valid in all gcc, clang and msvc.

Steps to reproduce:

  1. Write one the following test:
template <typename T>
concept HasField = requires { []() {}(); };

template <typename T>
    requires HasField<T>
consteval void Test()
{
}

int main()
{
    Test<int>();
}
  1. Wait for the intellisense error report on the Test<int>() with the following details:
[{
	"resource": "[PATH_TO_FILE]",
	"owner": "C/C++: IntelliSense",
	"code": "304",
	"severity": 8,
	"message": "no instance of function template \"Test\" matches the argument list",
	"source": "C/C++",
	"startLineNumber": 12,
	"startColumn": 5,
	"endLineNumber": 12,
	"endColumn": 9,
	"modelVersionId": 650,
	"origin": "extHost1"
}]

Expected behavior:

Configuration and Logs

-------- Diagnostics - 2/3/2026, 11:45:49 AM
Version: 1.30.3
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "e:/source/TestGame/**"
    ],
    "windowsSdkVersion": "10.0.26100.0",
    "compilerPath": "cl.exe",
    "cStandard": "c23",
    "cppStandard": "c++23",
    "configurationProvider": "ms-vscode.cmake-tools",
    "compileCommands": [
        "EDITED_PATH\\compile_commands.json"
    ],
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathInCppPropertiesJson": "cl.exe",
    "compileCommandsInCppPropertiesJson": [
        "build\\compile_commands.json"
    ],
    "configurationProviderInCppPropertiesJson": "ms-vscode.cmake-tools",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.intelliSenseUpdateDelay": 500,
    "C_Cpp.autocompleteAddParentheses": true,
    "C_Cpp.legacyCompilerArgsBehavior": true,
    "C_Cpp.autocomplete": "disabled",
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.workspaceSymbols": "All",
    "C_Cpp.doxygen.generatedStyle": "/**",
    "C_Cpp.codeAnalysis.updateDelay": 100,
    "C_Cpp.codeAnalysis.clangTidy.enabled": true,
    "C_Cpp.codeAnalysis.clangTidy.useBuildPath": true,
    "C_Cpp.vcpkg.enabled": false,
    "C_Cpp.experimentalFeatures": "enabled"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {},
    "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"
}
Custom browse configuration: 
{
    "browsePath": [
        "EDITED_PATH",
        "EDITED_PATH",
        "EDITED_PATH",
        "EDITED_PATH"
    ],
    "compilerPath": "c:/program files/llvm/bin/clang-cl.exe",
    "compilerArgs": [],
    "compilerFragments": [
        "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /EHs- /MDd /Zi /Ob0 /Od /RTC1 -clang:-std=c++23"
    ]
}
cpptools version (native): 1.30.2.0
Current database path: C:\USERS\EDITED_PATH\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\9DE1C39CDBB89B84DFD146C5CE357290\.BROWSE.VC.DB
Translation Unit Mappings:
[ EDITED_PATH.cpp - source TU]:
    EDITED_PATH
Translation Unit Configurations:
[ EDITED_PATH.cpp ]
    Process ID: 22292
    Memory Usage: 421 MB
    Compiler Path: C:\Program Files\LLVM\bin\clang-cl.exe
    Include paths:
        include: EDITED_PATH
        include: EDITED_PATH
        include: EDITED_PATH
        system include: C:\Program Files\LLVM\lib\clang\21\include
        system include: C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.50.35717\include
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\winrt
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\cppwinrt
    Defines:
        WIN32
        _WINDOWS
    Standard Version: c++23
    IntelliSense Mode: windows-clang-x64
    Other Flags:
        --clang
        --clang_version=210108
        --ms_compatibility
Total Memory Usage: 421 MB
Browse Paths from compile_commands.json, from workspace folder: EDITED_PATH
    C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.50.35717\include
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\cppwinrt
    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\ucrt
    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\winrt
    C:\Program Files\LLVM\lib\clang\21\include

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

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions