Assignment operators in til::spsc don't return anything #11940

Open
opened 2026-01-31 03:01:43 +00:00 by claunia · 0 comments
Owner

Originally created by @j4james on GitHub (Jan 3, 2021).

Originally assigned to: @lhecker on GitHub.

Environment

Windows build number: Version 10.0.18363.1198
Windows Terminal version (if applicable):

Steps to reproduce

I was trying to use the til::spsc class to do something like this:

auto channel = til::spsc::channel<QueueItem>(100);
auto producer = std::move(channel.first);
channel.first = std::move(producer);

Expected behavior

The code should compile.

Actual behavior

It fails with the error:

C:\terminal\src\inc\til\spsc.h(429): error C4716: 'til::spsc::producer<QueueItem>::operator=': must return a value

I believe the problem is that the assignment operators in the producer and consumer classes don't actually return anything.

See here:
ae550e0969/src/inc/til/spsc.h (L424-L428)

and here:
ae550e0969/src/inc/til/spsc.h (L542-L546)

I'm assuming they should have a return *this; or something along those lines.

Originally created by @j4james on GitHub (Jan 3, 2021). Originally assigned to: @lhecker on GitHub. # Environment Windows build number: Version 10.0.18363.1198 Windows Terminal version (if applicable): # Steps to reproduce I was trying to use the `til::spsc` class to do something like this: ``` auto channel = til::spsc::channel<QueueItem>(100); auto producer = std::move(channel.first); channel.first = std::move(producer); ``` # Expected behavior The code should compile. # Actual behavior It fails with the error: ``` C:\terminal\src\inc\til\spsc.h(429): error C4716: 'til::spsc::producer<QueueItem>::operator=': must return a value ``` I believe the problem is that the assignment operators in the `producer` and `consumer` classes don't actually return anything. See here: https://github.com/microsoft/terminal/blob/ae550e0969595f062b15c2ff5cc33d4afe8ebc3f/src/inc/til/spsc.h#L424-L428 and here: https://github.com/microsoft/terminal/blob/ae550e0969595f062b15c2ff5cc33d4afe8ebc3f/src/inc/til/spsc.h#L542-L546 I'm assuming they should have a `return *this;` or something along those lines.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11940