Skip to content

Commit d5739f0

Browse files
committed
coroutine_handle by_ref changed to by_val for avoiding ub
1 parent 857d241 commit d5739f0

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

library/include/p5/lambda/utils/async/future/front+inl.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ auto this_::Type<T>::operator co_await() const noexcept(true) {
140140
}
141141

142142
inline auto await_suspend(
143-
::std::coroutine_handle<> const &coroutine
143+
::std::coroutine_handle<> coroutine
144144
) const noexcept(false) {
145145
if (context_.subscription) throw parent_::exceptions::BadState{};
146146
if (context_.instance) throw parent_::exceptions::BadState{};

library/include/p5/lambda/utils/async/task/promise+inl.hxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ auto final_suspend() noexcept(true) {
3535
}
3636

3737
inline auto await_suspend(
38-
typename Policy::Coroutine const &coroutine
38+
typename Policy::Coroutine coroutine
3939
) noexcept(true) {
4040
if (::std::exchange(suspended_, true)) return false;
4141
if (! coroutine) return false;
@@ -73,7 +73,7 @@ auto initial_suspend() noexcept(true) {
7373
}
7474

7575
inline auto await_suspend(
76-
Coroutine_ const &coroutine
76+
Coroutine_ coroutine
7777
) noexcept(true) {
7878
if (coroutine_) return;
7979
coroutine_.emplace(nullptr);
@@ -185,7 +185,7 @@ auto await_transform(auto &&awaitable) noexcept(false) {
185185
}
186186

187187
inline static auto await_suspend(
188-
ChildCoroutine_ const &coroutine
188+
ChildCoroutine_ coroutine
189189
) noexcept(true) { return coroutine.promise().context_.parent; }
190190

191191
inline constexpr static auto await_resume() noexcept(true) {}
@@ -226,7 +226,7 @@ auto await_transform(auto &&awaitable) noexcept(false) {
226226
return false;
227227
}
228228

229-
inline auto await_suspend(Coroutine_ const &coroutine) noexcept(false) {
229+
inline auto await_suspend(Coroutine_ coroutine) noexcept(false) {
230230
if (
231231
(! coroutine) || coroutine.done()
232232
) throw ::std::invalid_argument{"bad coroutine"};
@@ -305,7 +305,7 @@ auto await_transform(auto &&awaitable) noexcept(false) {
305305
ChildCoroutine_ coroutine;
306306

307307
inline ChildTask_(
308-
ChildCoroutine_ const &coroutine
308+
ChildCoroutine_ coroutine
309309
) noexcept(true): coroutine{coroutine} {}
310310
};
311311

library/include/p5/lambda/utils/async/task/type+inl.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ template <class T> inline auto this_::Type<T>::start() const noexcept(true) {
8585
}
8686

8787
template <class T> inline this_::Type<T>::Type(
88-
::std::decay_t<decltype(coroutine_)> const &coroutine
88+
::std::decay_t<decltype(coroutine_)> coroutine
8989
) noexcept(false): future_{}, coroutine_{coroutine} {
9090
using Bad_ = ::std::invalid_argument;
9191
if (! coroutine) throw Bad_{"bad coroutine"};

library/include/p5/lambda/utils/async/task/type.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private:
3535

3636
public:
3737
Type() noexcept(true) = default;
38-
Type(::std::decay_t<decltype(coroutine_)> const &) noexcept(false);
38+
Type(::std::decay_t<decltype(coroutine_)>) noexcept(false);
3939

4040
Type(Type &&) noexcept(true);
4141
Type(Type const &) noexcept(true);

library/include/p5/lambda/utils/container/pointer+inl.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ auto this_::Type<Interface>::operator co_await() const noexcept(true) {
126126
}
127127

128128
inline auto await_suspend(
129-
::std::coroutine_handle<> const &coroutine
129+
::std::coroutine_handle<> coroutine
130130
) const noexcept(false) {
131131
if (context_.subscription) throw ::std::logic_error{"bad state"};
132132
if (await_ready()) {

library/include/p5/lambda/utils/generator+inl.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ this_::Type<T>::operator == (
269269
}
270270

271271
template <class T> inline constexpr
272-
this_::Type<T>::Type(parent_::Handle_<T> const &coroutine) noexcept(true):
272+
this_::Type<T>::Type(parent_::Handle_<T> coroutine) noexcept(true):
273273
coroutine_{coroutine}
274274
{
275275
if (! coroutine_) return;
@@ -293,7 +293,7 @@ auto this_::Type<T>::begin() const noexcept(true) {
293293
}
294294

295295
template <class T> inline constexpr this_::Type<T>::Type(
296-
this_::Handle_<T> const &coroutine
296+
this_::Handle_<T> coroutine
297297
) noexcept(true): coroutine_{coroutine} {}
298298

299299
template <class T> inline this_::Type<T>::Type::~Type() noexcept(true) {

library/include/p5/lambda/utils/generator.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ template <class T> struct Type final {
183183
::std::default_sentinel_t const &
184184
) const noexcept(true);
185185

186-
constexpr explicit Type(Handle_<T> const &coroutine) noexcept(true);
186+
constexpr explicit Type(Handle_<T> coroutine) noexcept(true);
187187

188188
private:
189189
Handle_<T> coroutine_;
@@ -202,7 +202,7 @@ template <class T> struct Type final:
202202
constexpr auto end() const noexcept(true);
203203
constexpr auto begin() const noexcept(true);
204204

205-
constexpr explicit Type(Handle_<T> const &coroutine) noexcept(true);
205+
constexpr explicit Type(Handle_<T> coroutine) noexcept(true);
206206

207207
~Type() noexcept(true);
208208
constexpr Type() noexcept(true) = default;

library/tests/utils/src/async.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ BOOST_AUTO_TEST_CASE(future_case) {
146146

147147
inline constexpr static auto initial_suspend() noexcept(true) {
148148
return ::std::suspend_never{};
149-
};
149+
}
150150

151151
inline constexpr static auto final_suspend() noexcept(true) {
152152
return ::std::suspend_always{};
153-
};
153+
}
154154

155155
inline auto return_value(Value_ &value) noexcept(true) {
156156
pointer_ = &value;
@@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(future_case) {
171171
inline ~Result_() noexcept(true) { handle_.destroy(); }
172172

173173
inline Result_(
174-
::std::coroutine_handle<promise_type> const &handle
174+
::std::coroutine_handle<promise_type> handle
175175
) noexcept(true): handle_{handle} {}
176176

177177
private:

0 commit comments

Comments
 (0)