Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Coroutines: error when non-copyable/non-movable returned from `await_resume`

未关闭
#14,244 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp
领域
devtools

调研方向

首先,使用 C++20 和所述的 Windows MSVC IntelliSense 配置,在 main.cpp 中复现该报告。当 await_resume 返回不可复制的 foo 时,跟踪 co_await 表达式处的诊断;当 IntelliSense 不再报告错误波浪线,而列出的编译器仍继续接受该代码时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug Language Service parser Visual Studio
Environment
  • OS and Version: Windows 11 25H2
  • VS Code Version: 1.110.0
  • C/C++ Extension Version: 1.30.5
  • If using SSH remote, specify OS of remote machine: None

When returning a non-copyable and non-movable value from await_resume of an awaiter, intellisense reports this error at the co_await point (using MSVC as compiler): function "foo::foo(foo &&)" cannot be referenced -- it is a deleted function.

Nevertheless, MSVC, GCC and Clang accept the code and the program behaves as expected.

Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce: Paste the following snippet:

#include <coroutine>
#include <exception>

struct fire_and_forget final
{
    struct promise_type;
};

struct fire_and_forget::promise_type final
{
    static constexpr fire_and_forget get_return_object() noexcept { return {}; }
    static constexpr std::suspend_never initial_suspend() noexcept { return {}; }
    static constexpr std::suspend_never final_suspend() noexcept { return {}; }

    static constexpr void return_void() noexcept {}
    inline static void unhandled_exception() noexcept { std::terminate(); }
};


struct foo final
{
    foo() = default;

    foo(foo const &) = delete;
    foo &operator=(foo const &) = delete;

    foo(foo &&) = delete;
    foo &operator=(foo &&) = delete;
};

struct my_awaiter final
{
    bool await_ready() { return false; }
    void await_suspend(auto) {}
    foo await_resume() { return foo{}; }
};

fire_and_forget test()
{
    auto x = co_await my_awaiter{}; // error here
}

Expected behavior: No error squiggles

Configuration and Logs
// c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/src"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.26100.0",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

C/C++: Log Diagnostics

-------- Diagnostics - 3/5/2026, 12:04:00 PM
Version: 1.30.5
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "<User>/thing/cpp/entt_scheduler_demo/**",
        "<User>/thing/cpp/entt_scheduler_demo/src"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.26100.0",
    "intelliSenseMode": "windows-msvc-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "cStandard": "c17",
    "cppStandard": "c++20",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "compilerPath": "${env:CXX}",
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.inlayHints.autoDeclarationTypes.enabled": true,
    "C_Cpp.inlayHints.parameterNames.enabled": true,
    "C_Cpp.autocompleteAddParentheses": true,
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.default.compilerPath": "${env:CXX}",
    "C_Cpp.default.cStandard": "c17",
    "C_Cpp.default.cppStandard": "c++20",
    "C_Cpp.commentContinuationPatterns": [
        "/*"
    ],
    "C_Cpp.codeAnalysis.clangTidy.enabled": true,
    "C_Cpp.codeAnalysis.clangTidy.args": [
        "-isystem=CMakeLists.txt",
        "*"
    ],
    "C_Cpp.codeAnalysis.clangTidy.checks.disabled": [
        "cppcoreguidelines-avoid-magic-numbers",
        "cppcoreguidelines-avoid-c-arrays",
        "fuchsia-default-arguments-calls",
        "fuchsia-default-arguments-declarations",
        "fuchsia-overloaded-operator",
        "hicpp-avoid-c-arrays",
        "llvm-include-order",
        "llvm-header-guard",
        "llvmlibc-*",
        "modernize-avoid-c-arrays",
        "readability-magic-numbers"
    ],
    "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"
}
cpptools version (native): 1.30.5.0
Current database path: <User>\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\8867B49488CF20A004321616C2AF107D\.BROWSE.VC.DB
Translation Unit Mappings:
[ <User>\thing\cpp\entt_scheduler_demo\main.cpp - source TU]:
Translation Unit Configurations:
[ <User>\thing\cpp\entt_scheduler_demo\main.cpp ]
    Process ID: 25624
    Memory Usage: 85 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\bin\Hostx64\x64\cl.exe
    Include paths:
        include: <User>\thing\cpp\entt_scheduler_demo\src
        system include: C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include
        system include: C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\atlmfc\include
        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\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\winrt
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\cppwinrt
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c++20
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 85 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 5892
Other Extensions

No response

Additional context

No response

主要语言
TypeScript
星标
6.2k
派生
1.7k
平均合并
1 天 4 小时
30 天内合并 PR
58

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/vscode-cpptools 的其他 Issue

查看 microsoft/vscode-cpptools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。