-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix thrust::optional<T&>::emplace() #1707
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for addressing the issue. I have some minor comments
thrust/thrust/optional.h
Outdated
_CCCL_HOST_DEVICE T& emplace(Args&&... args) noexcept | ||
{ | ||
static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args"); | ||
static_assert(sizeof...(Args) == 1, "Args must be a single lvalue"); | ||
static_assert(std::is_lvalue_reference<Args...>::value, "Args must be a single lvalue"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather change the function signature to just take a _Arg&
instead of variadics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my initial preference, but I didn't want to change the interface. I guess functionally the change would still be the same as changing the interface anyway, so it wouldn't matter technically.
6fd9c5e
to
758148b
Compare
pre-commit.ci autofix |
/ok to test |
Where optional<T> inherits optional<T>::construct via a series of classes, optional<T&> does not. This means that optional<T&>::emplace() was broken and called into a member function that did not exist. This replaces the functionality to make optional<T&>::emplace() change the stored reference to the new one. Note that it does _not_ emplace the referee, as this would lead to questionable behavior when the optional holds nullopt. This was revealed by a change in LLVM, see llvm/llvm-project#90152 and ROCm/rocThrust#404.
758148b
to
5864eed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miscco Is the regressions directory the right place to put the test? I've noticed that they are disabled currently. I'm fine with moving, I wasn't sure what the proper place was otherwise. |
I just realized, that there are no tests against thrust optional at all 🤦♂️ |
/ok to test |
🟩 CI Results [ Failed: 0 | Passed: 198 | Total: 198 ]
|
# | Runner |
---|---|
154 | linux-amd64-cpu16 |
16 | linux-arm64-cpu16 |
16 | linux-amd64-gpu-v100-latest-1 |
12 | windows-amd64-cpu16 |
👃 Inspect Changes
Modifications in project?
Project | |
---|---|
CCCL Infrastructure | |
libcu++ | |
CUB | |
+/- | Thrust |
Modifications in project or dependencies?
Project | |
---|---|
CCCL Infrastructure | |
libcu++ | |
+/- | CUB |
+/- | Thrust |
Description
closes #1706
Where optional inherits optional::construct via a series of classes, optional<T&> does not. This means that optional<T&>::emplace() was broken and called into a member function that did not exist.
This replaces the functionality to make optional<T&>::emplace() change the stored reference to the new one. Note that it does not emplace the referee, as this would lead to questionable behavior when the optional holds nullopt.
This was revealed by a change in LLVM, see
llvm/llvm-project#90152 and ROCm/rocThrust#404.
Checklist