Skip to content

LWG-4158 packaged_task::operator= should abandon its shared state - #6488

Open
Zhuo Ming (Pen-NineCat) wants to merge 1 commit into
microsoft:mainfrom
Pen-NineCat:main
Open

Zhuo Ming (Pen-NineCat) wants to merge 1 commit into
microsoft:mainfrom
Pen-NineCat:main

Conversation

@Pen-NineCat

@Pen-NineCat Zhuo Ming (Pen-NineCat) commented Oct 15, 2026 •

Copy link
Copy Markdown

Resolves https://cplusplus.github.io/LWG/issue4158

Implement packaged_task& operator=(packaged_task&&) with

packaged_task(_STD move(_Other)).swap(*this);

Close #6315

Maybe an other problem:

The self-assignment test (not in current PR)

{
     std::packaged_task<int()> task([] { return 42; });
     task = std::move(task);
     assert(task.valid());
}

passes on most configurations but fails on 5/46 (all /std:c++latest, mixed /MT//MDd).

Failed Tests (5):
  std :: tests/LWG4158_packaged_task_move_assignment:41
  std :: tests/LWG4158_packaged_task_move_assignment:42
  std :: tests/LWG4158_packaged_task_move_assignment:43
  std :: tests/LWG4158_packaged_task_move_assignment:44
  std :: tests/LWG4158_packaged_task_move_assignment:45

I don't know why only these configurations fail. My implementation follows the proposed resolution packaged_task(std::move(rhs)).swap(*this), so I expected task to stay valid after self-move-assignment. Could this be a separate issue, or is my test wrong? I'm not sure if self-move-assignment is supposed to be covered by this test at all.

@Pen-NineCat
Zhuo Ming (Pen-NineCat) requested a review from a team as a code owner October 15, 2026 15:24
Copilot AI balanced review requested due to automatic review settings October 15, 2026 15:24
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Oct 15, 2026

This comment was marked as resolved.

@azure-pipelines

This comment was marked as resolved.

@Pen-NineCat

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation reuses existing abandonment behavior, and the regression test covers the reported defect.

0 open findings

🧠 Review effort: Balanced

@StephanTLavavej

Copy link
Copy Markdown
Member

Can you please edit your PR description to properly auto-close our tracking issue? See https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests . You need to literally say Close #6315 in your PR description to activate this functionality. Instead, your PR description has a much more complicated link Close https://github.com/orgs/microsoft/projects/1152/views/1?pane=issue&itemId=201549613&issue=microsoft%7CSTL%7C6315 even though it happens to be displayed the same way.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the LWG Library Working Group issue label Oct 19, 2026
@StephanTLavavej

This comment was marked as resolved.

@azure-pipelines

This comment was marked as resolved.

@Pen-NineCat

Copy link
Copy Markdown
Author

Sorry for the confusion — I've updated the PR description to use Close #6315. Thanks for the clarification!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LWG Library Working Group issue

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

LWG-4158 packaged_task::operator= should abandon its shared state

3 participants