microsoft / microsoft/vscode-cpptools

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

Offen
#13,665 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug Language Service Visual Studio
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die drei Beispiele in einer eigenständigen .cpp-Datei mit aktiviertem C++23 zu reproduzieren, und vergleiche die IntelliSense-Diagnosen mit g++ 15.1.1. Der Payload nennt keine vscode-cpptools-Quelldatei und keinen Test; als erledigt gilt die Aufgabe, wenn die initializer-list-Form mit einem front attribute konsistent mit der anderen gültigen Form geparst wird und durch Regressionstests abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
compilers, tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.