Skip to content

Commit 17bf2c4

Browse files
authored
Merge pull request #2155 from RobertLeahy/ipa_modref_20260805
asioexec::completion_token: Fix Miscompiling Test
2 parents a85c977 + f960622 commit 17bf2c4

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

test/exec/asio/test_completion_token.cpp

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
using namespace STDEXEC;
3939
using namespace exec::asio;
4040

41+
#if STDEXEC_GCC() && STDEXEC_GCC_VERSION >= 1400 && STDEXEC_GCC_VERSION < 1500
42+
// Work around a GCC 14 IPA mod/ref miscompilation in this test.
43+
# pragma GCC optimize("no-ipa-modref")
44+
#endif
45+
4146
namespace
4247
{
4348

@@ -354,36 +359,20 @@ namespace
354359
std::shared_ptr<void>& ptr,
355360
CompletionToken&& token)
356361
{
357-
// This function is seemingly fragile?
358-
//
359-
// In release mode slightly different arrangements produce bizarre outcomes:
360-
//
361-
// /root/stdexec/test/asioexec/test_completion_token.cpp:380: FAILED:
362-
// CHECK( !ex )
363-
// with expansion:
364-
// false
365-
//
366-
// /root/stdexec/test/asioexec/test_completion_token.cpp:382: FAILED:
367-
// CHECK( ptr.use_count() == 1U )
368-
// with expansion:
369-
// -1564306560 == 1
370362
using signature_type = void();
371363
return asio_impl::async_initiate<CompletionToken, signature_type>(
372364
[&ptr](auto h, auto const & ex)
373365
{
374366
auto local = std::make_shared<decltype(h)>(std::move(h));
375367
auto const assoc = asio_impl::get_associated_executor(*local, ex);
376368
ptr = local;
377-
asio_impl::post(assoc,
378-
[&ptr, local = std::move(local)]() mutable
379-
{
380-
CHECK(local.use_count() == 2);
381-
CHECK(ptr.use_count() == 2);
382-
auto cpy = std::move(local);
383-
cpy.reset();
384-
CHECK(ptr.use_count() == 1);
385-
throw std::logic_error("Test");
386-
});
369+
asio_impl::post(ex,
370+
asio_impl::bind_executor(assoc,
371+
[local]() mutable
372+
{
373+
local.reset();
374+
throw std::logic_error("Test");
375+
}));
387376
},
388377
token,
389378
ex);
@@ -394,7 +383,7 @@ namespace
394383
"completion handler's lifetime (this is necessary in situations where "
395384
"asynchronous control flow bifurcates and one of the child operations ends "
396385
"via exception)",
397-
"[asioexec][completion_token][!mayfail]")
386+
"[asioexec][completion_token]")
398387
{
399388
std::exception_ptr ex;
400389
std::shared_ptr<void> ptr;

0 commit comments

Comments
 (0)