From cad203d5b2dc660b15ccbb3ebdb902bdcd634eb5 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Wed, 26 Jun 2024 19:39:28 +1000 Subject: [PATCH] Fix experimental::coro compatibility with Apple clang 15. --- .../asio/experimental/detail/coro_promise_allocator.hpp | 4 ++-- asio/include/asio/experimental/detail/partial_promise.hpp | 4 ++-- asio/src/tests/unit/experimental/coro/exception.cpp | 5 ++++- asio/src/tests/unit/experimental/coro/simple_test.cpp | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/asio/include/asio/experimental/detail/coro_promise_allocator.hpp b/asio/include/asio/experimental/detail/coro_promise_allocator.hpp index 328646968f..aebab8c4e2 100644 --- a/asio/include/asio/experimental/detail/coro_promise_allocator.hpp +++ b/asio/include/asio/experimental/detail/coro_promise_allocator.hpp @@ -94,14 +94,14 @@ struct coro_promise_allocator allocator_type get_allocator() const {return alloc_;} template - void* operator new(const std::size_t size, Args & ... args) + void* operator new(std::size_t size, Args & ... args) { return allocate_coroutine(size, get_variadic...>() + 1u>(args...)); } - void operator delete(void* raw, const std::size_t size) + void operator delete(void* raw, std::size_t size) { deallocate_coroutine(raw, size); } diff --git a/asio/include/asio/experimental/detail/partial_promise.hpp b/asio/include/asio/experimental/detail/partial_promise.hpp index 8495af2f0b..842f8b3237 100644 --- a/asio/include/asio/experimental/detail/partial_promise.hpp +++ b/asio/include/asio/experimental/detail/partial_promise.hpp @@ -54,12 +54,12 @@ template struct partial_promise_base { template - void* operator new(const std::size_t size, Executor&, Token& tk, Args&...) + void* operator new(std::size_t size, Executor&, Token& tk, Args&...) { return allocate_coroutine(size, get_associated_allocator(tk)); } - void operator delete(void* raw, const std::size_t size) + void operator delete(void* raw, std::size_t size) { deallocate_coroutine(raw, size); } diff --git a/asio/src/tests/unit/experimental/coro/exception.cpp b/asio/src/tests/unit/experimental/coro/exception.cpp index f4d782e990..e9fe5c8821 100644 --- a/asio/src/tests/unit/experimental/coro/exception.cpp +++ b/asio/src/tests/unit/experimental/coro/exception.cpp @@ -61,7 +61,10 @@ asio::experimental::coro throwing_generator( int i = 0; while (i < 3) - co_yield last = ++i; + { + last = ++i; + co_yield last; + } throw std::runtime_error("throwing-generator"); } diff --git a/asio/src/tests/unit/experimental/coro/simple_test.cpp b/asio/src/tests/unit/experimental/coro/simple_test.cpp index 5eac068854..f37159e431 100644 --- a/asio/src/tests/unit/experimental/coro/simple_test.cpp +++ b/asio/src/tests/unit/experimental/coro/simple_test.cpp @@ -82,7 +82,10 @@ asio::experimental::coro generator_impl( int i = 0; while (true) - co_yield last = ++i; + { + last = ++i; + co_yield last; + } } asio::awaitable generator_test()