Skip to content

Fix build with gcc 11.3.0 (resolves #57)#58

Merged
danvratil merged 1 commit intomainfrom
fix-gcc11.3-build
Apr 27, 2022
Merged

Fix build with gcc 11.3.0 (resolves #57)#58
danvratil merged 1 commit intomainfrom
fix-gcc11.3-build

Conversation

@danvratil
Copy link
Collaborator

QCoro::detail::QCoroSignal is not a copy-constructible class
(it contains std::unique_ptr), but when calling co_await,
gcc tried to make a copy of coroSignal either when evaluating
the expression after co_await, or when passing the result of
the expression to Task<T>::await_transform(). This is despite
Task::await_transform() having an overload that accepts reference
or an lvalue reference to the object.

I do believe this might be a regression in gcc 11.3, since it worked
in gcc 11.2 and it works with clang as well. The C++ standard does
not specify any constraints regarding how the result of the expression
after the co_await keyword should be passed to await_transform.

As a workaround, we co_await a temporary QCoroSignal, which gcc seems
to correctly pass down as a lvalue reference, so no issues with copying.
Explictly std::move()ing coroSignal to co_await would also work,
but it's weird.

I haven't confirmed whether this is a bug yet, as I first need to put
together a small reproducer case.

QCoro::detail::QCoroSignal is not a copy-constructible class
(it contains std::unique_ptr), but when calling co_await,
gcc tried to make a copy of coroSignal either when evaluating
the expression after `co_await`, or when passing the result of
the expression to `Task<T>::await_transform()`. This is despite
Task::await_transform() having an overload that accepts reference
or an lvalue reference to the object.

I do believe this might be a regression in gcc 11.3, since it worked
in gcc 11.2 and it works with clang as well. The C++ standard does
not specify any constraints regarding how the result of the expression
after the co_await keyword should be passed to `await_transform`.

As a workaround, we co_await a temporary QCoroSignal, which gcc seems
to correctly pass down as a lvalue reference, so no issues with copying.
Explictly `std::move()`ing `coroSignal` to `co_await` would also work,
but it's weird.

I haven't confirmed whether this is a bug yet, as I first need to put
together a small reproducer case.
@github-actions
Copy link
Contributor

Unit Test Results

  6 files   -   1    6 suites   - 1   4m 5s ⏱️ -45s
14 tests ±  0  14 ✔️ +  1  0 💤 ±0  0  - 1 
80 runs   - 14  80 ✔️  - 13  0 💤 ±0  0  - 1 

Results for commit 1cbab28. ± Comparison against base commit 826dbb5.

@danvratil danvratil merged commit 375f2d1 into main Apr 27, 2022
@danvratil danvratil deleted the fix-gcc11.3-build branch April 27, 2022 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant