2626#include " __receivers.hpp"
2727
2828#include < exception>
29+ #include < iostream>
30+ #include < sstream>
2931#include < utility>
3032
3133STDEXEC_PRAGMA_PUSH ()
3234STDEXEC_PRAGMA_IGNORE_GNU(" -Wsubobject-linkage" )
3335
36+ #define STDEXEC_DEBUG_PRINT (...) \
37+ (std::cout << (std::stringstream() << __FILE__ << ' :' << __LINE__ << ' ' \
38+ << __VA_ARGS__ << ' \n ' ).str())
39+
3440namespace STDEXEC
3541{
3642#if !STDEXEC_NO_STDCPP_COROUTINES()
@@ -216,6 +222,9 @@ namespace STDEXEC
216222 auto && __awaitable = __get_awaitable (static_cast <_Awaitable&&>(__source),
217223 __coro.promise ());
218224
225+ STDEXEC_DEBUG_PRINT (" address of awaitable: " << (void *) std::addressof (__awaitable)
226+ << " , address of source: "
227+ << (void *) std::addressof (__source));
219228 STDEXEC_ASSERT (std::addressof (__awaitable) == std::addressof (__source));
220229 }
221230
@@ -287,6 +296,10 @@ namespace STDEXEC
287296
288297 [[maybe_unused]]
289298 auto && __awaiter = __get_awaiter (static_cast <__awaiter_t &&>(__awaiter_));
299+
300+ STDEXEC_DEBUG_PRINT (" address of awaiter: " << (void *) std::addressof (__awaiter)
301+ << " , address of source: "
302+ << (void *) std::addressof (__source));
290303 STDEXEC_ASSERT (std::addressof (__awaiter) == std::addressof (__awaiter_));
291304 }
292305
@@ -400,6 +413,10 @@ namespace STDEXEC
400413 explicit (!STDEXEC_EDG()) __promise([[maybe_unused]]
401414 __opstate_t & __opstate) noexcept
402415 {
416+ STDEXEC_DEBUG_PRINT (" __promise_offset: "
417+ << __promise_offset << " , actual offset: "
418+ << (reinterpret_cast <std::byte*>(this ) - __opstate.__storage_ ));
419+
403420 STDEXEC_ASSERT (__promise_offset
404421 == reinterpret_cast <std::byte*>(this ) - __opstate.__storage_ );
405422 }
@@ -416,6 +433,8 @@ namespace STDEXEC
416433 // the first implementation of storing the coroutine frame inline in __opstate using the
417434 // technique in this file is due to Lewis Baker <lewissbaker@gmail.com>, and was first
418435 // shared at https://godbolt.org/z/zGG9fsPrz
436+ STDEXEC_DEBUG_PRINT (" __bytes: " << __bytes << " , storage size " << (__storage_size + 1 ));
437+
419438 STDEXEC_ASSERT (__bytes == __storage_size + 1 );
420439 return __opstate.__storage_ ;
421440 }
@@ -568,6 +587,9 @@ namespace STDEXEC
568587 }
569588 STDEXEC_CATCH_ALL
570589 {
590+ STDEXEC_DEBUG_PRINT (" Commiting UB in the face of an exception thrown from "
591+ " resume()" );
592+
571593 STDEXEC_ASSERT (false
572594 && " about to deliberately commit UB in response to a misbehaving "
573595 " awaitable" );
@@ -681,4 +703,6 @@ namespace STDEXEC
681703 inline constexpr __connect_awaitable_t __connect_awaitable{};
682704} // namespace STDEXEC
683705
706+ #undef STDEXEC_DEBUG_PRINT
707+
684708STDEXEC_PRAGMA_POP ()
0 commit comments