Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions include/stdexec/__detail/__config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,14 @@ namespace STDEXEC::__std
#define STDEXEC_ATTRIBUTE_CASE_DEFAULT(...) [[__VA_ARGS__]]

// [[no_unique_address]]
#if (STDEXEC_NVHPC() && STDEXEC_NVHPC_VERSION < 2305) \
|| (STDEXEC_MSVC() && STDEXEC_MSVC_VERSION < 1943) \
// MSVCBUG https://developercommunity.visualstudio.com/t/Incorrect-codegen-when-using-msvc::no_/10452874
// [[msvc::no_unique_address]] still miscompiles on current MSVC, overrunning stack objects
// and corrupting data (see https://github.com/NVIDIA/stdexec/issues/2099), so it is disabled
// for all MSVC versions until a fixed compiler can be gated on.
#if (STDEXEC_NVHPC() && STDEXEC_NVHPC_VERSION < 2305) || STDEXEC_MSVC() \
|| (STDEXEC_CLANG_CL() && STDEXEC_CLANG_VERSION < 1801)
# define STDEXEC_ATTRIBUTE_CASE_NO_UNIQUE_ADDRESS
#elif STDEXEC_CLANG_CL() || STDEXEC_MSVC()
#elif STDEXEC_CLANG_CL()
# define STDEXEC_ATTRIBUTE_CASE_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
#else
# define STDEXEC_ATTRIBUTE_CASE_NO_UNIQUE_ADDRESS [[no_unique_address]]
Expand Down
6 changes: 0 additions & 6 deletions test/exec/test_fork_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,7 @@ namespace

CHECK(counter::copy_constructions == 0);
CHECK(counter::copy_assignments == 0);
#if STDEXEC_MSVC()
// TODO: MSVC drops the initialization entirely, even though there is an observable side effect (atomic increment).
// See https://github.com/NVIDIA/stdexec/pull/2302#issuecomment-6110273094.
CHECK(counter::move_constructions == 0);
#else
CHECK(counter::move_constructions == 1);
#endif
CHECK(counter::move_assignments == 0);

CHECK(witness == 2);
Expand Down
19 changes: 19 additions & 0 deletions test/stdexec/algos/adaptors/test_let_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import std;
#else
# include <chrono> // IWYU pragma: keep for chrono_literals
# include <cstdint>
# include <exception>
# include <memory>
#endif
Expand Down Expand Up @@ -82,6 +83,24 @@ namespace
STDEXEC::sync_wait(std::move(snd));
}

// Regression test for https://github.com/NVIDIA/stdexec/issues/2099: MSVC miscompiled
// the layout of [[msvc::no_unique_address]] members, so constructing this sender wrote
// past the end of a stack temporary and corrupted the captured values.
TEST_CASE("let_value preserves a function's captures alongside a nested sender",
"[adaptors][let_value]")
{
auto work = ex::just() | ex::let_value([] { return ex::just(); });
auto snd = ex::just(std::uintptr_t{0x1111})
| ex::let_value([sentinel = 0x5A5A5A5A, work](std::uintptr_t v)
{
(void) work;
return ex::just(sentinel, v);
});
auto [sentinel, v] = STDEXEC::sync_wait(std::move(snd)).value();
CHECK(sentinel == 0x5A5A5A5A);
CHECK(v == 0x1111);
}

TEST_CASE("let_value can be used to produce values", "[adaptors][let_value]")
{
ex::sender auto snd = ex::just() | ex::let_value([] { return ex::just(13); });
Expand Down