microsoft / microsoft/vscode-cpptools

(C++23) Fails to parse a particular lambda expression within an initializer list

Open
#13,665 2 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: Fedora Linux 42 (Workstation Edition)
  • VS Code Version: 1.100.2
  • C/C++ Extension Version: 1.25.3
  • If using SSH remote, specify OS of remote machine: _
Bug Summary and Steps to Reproduce

Bug Summary:
Having a lambda expression that contains a front attribute, when inside an initializer list, triggers a syntax error.

Steps to reproduce:

  1. Copy-paste this code snippet in a cpp file :
#include <vector>
#include <functional>

// example #1: works
std::function<void()> a = [] [[noreturn]] () {};

// example #2: works
auto b = std::function<void()>{[] () {}};

// example #3: doesn't work
auto c = std::function<void()>{[] [[noreturn]] () {}};

Expected behavior:
Based on this C++23 "spec" there should be no syntax error reported
-> https://en.cppreference.com/w/cpp/language/lambda.html
(see under Explanation > front-attr)
But even if the spec is wrong, it should at least stay consistent between example #1 and #3 (both fails or both pass)
(though g++ 15.1.1 parses it fine)

Configuration and Logs
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/include",
                "${workspaceFolder}/monlang-parser/include",
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c23",
            "cppStandard": "c++23",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

-------- Diagnostics - 6/3/2025, 9:28:25 AM
Version: 1.25.3
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/motyak/devv/monlang-interpreter/include",
        "/home/motyak/devv/monlang-interpreter/monlang-parser/include"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/g++",
    "cStandard": "c23",
    "cppStandard": "c++23",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathInCppPropertiesJson": "/usr/bin/g++",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.loggingLevel": "Debug",
    "C_Cpp.autoAddFileAssociations": false
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.cpp": "cpp"
    },
    "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,
        "monlang-LV1/*": true,
        "monlang-parser/*": true,
        "lib/monlang-LV1/*": true,
        "lib/monlang-LV2/*": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.25.3.0
Current database path: /home/motyak/.cache/vscode-cpptools/d4fd19c9f7621ce3aa4ae46b901a0e1a/.browse.VC.db
Translation Unit Mappings:
[ /home/motyak/devv/monlang-interpreter/src/builtin/exit.cpp - source TU]:
Translation Unit Configurations:
[ /home/motyak/devv/monlang-interpreter/src/builtin/exit.cpp ]
    Process ID: 8917
    Memory Usage: 142 MB
    Compiler Path: /usr/bin/g++
    Include paths:
        include: /home/motyak/devv/monlang-interpreter/include
        include: /home/motyak/devv/monlang-interpreter/monlang-parser/include
        system include: /usr/include/c++/15
        system include: /usr/include/c++/15/x86_64-redhat-linux
        system include: /usr/include/c++/15/backward
        system include: /usr/lib/gcc/x86_64-redhat-linux/15/include
        system include: /usr/local/include
        system include: /usr/include
    Standard Version: c++23
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=150101
Total Memory Usage: 142 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 8560
Number of files parsed: 1130-------- Diagnostics - 6/3/2025, 9:28:25 AM
Version: 1.25.3
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/motyak/devv/monlang-interpreter/include",
        "/home/motyak/devv/monlang-interpreter/monlang-parser/include"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/g++",
    "cStandard": "c23",
    "cppStandard": "c++23",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathInCppPropertiesJson": "/usr/bin/g++",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.loggingLevel": "Debug",
    "C_Cpp.autoAddFileAssociations": false
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.cpp": "cpp"
    },
    "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,
        "monlang-LV1/*": true,
        "monlang-parser/*": true,
        "lib/monlang-LV1/*": true,
        "lib/monlang-LV2/*": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.25.3.0
Current database path: /home/motyak/.cache/vscode-cpptools/d4fd19c9f7621ce3aa4ae46b901a0e1a/.browse.VC.db
Translation Unit Mappings:
[ /home/motyak/devv/monlang-interpreter/src/builtin/exit.cpp - source TU]:
Translation Unit Configurations:
[ /home/motyak/devv/monlang-interpreter/src/builtin/exit.cpp ]
    Process ID: 8917
    Memory Usage: 142 MB
    Compiler Path: /usr/bin/g++
    Include paths:
        include: /home/motyak/devv/monlang-interpreter/include
        include: /home/motyak/devv/monlang-interpreter/monlang-parser/include
        system include: /usr/include/c++/15
        system include: /usr/include/c++/15/x86_64-redhat-linux
        system include: /usr/include/c++/15/backward
        system include: /usr/lib/gcc/x86_64-redhat-linux/15/include
        system include: /usr/local/include
        system include: /usr/include
    Standard Version: c++23
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=150101
Total Memory Usage: 142 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 8560
Number of files parsed: 1130
Other Extensions

No response

Additional context

No response

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

Start by reproducing the three examples in a standalone .cpp file with C++23 enabled, comparing IntelliSense diagnostics with g++ 15.1.1. The payload names no vscode-cpptools source file or test; done means the initializer-list form with a front attribute is parsed consistently with the other valid form and has regression coverage.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.