You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A recent change in clang revealed a problem in the implementation of thrust::optional<T&>::emplace(): it's calling this->construct(), which is not available on optional<T&>. Upon further investigation it seems that calling construct() here is not the right approach, as the address that the optional holds should be changed instead. This was reported as a bug to rocThrust, but it would be nice to have a fix upstream also.
Construct a thrust::optional<int&> (or any other optional holding a reference).
Use the emplace() method
Compilation fails with error message
thrust/optional.h(2756): error: class "thrust::optional<int &>" has no member "construct"
this->construct(std::forward<Args>(args)...);
^
detected during instantiation of "T &thrust::optional<T &>::emplace(Args &&...) [with T=int, Args=<int &>]" at line 12 of <source>
Expected behavior
From the implementation of the other operations in thrust::optional<T&>, it seems that emplace() on optional<T&> should replace the optional's value with the address of the operand, to construct a new T&, rather than try to construct a new T.
Is this a duplicate?
Type of Bug
Compile-time Error
Component
Thrust
Describe the bug
A recent change in clang revealed a problem in the implementation of
thrust::optional<T&>::emplace()
: it's callingthis->construct()
, which is not available onoptional<T&>
. Upon further investigation it seems that callingconstruct()
here is not the right approach, as the address that the optional holds should be changed instead. This was reported as a bug to rocThrust, but it would be nice to have a fix upstream also.See llvm/llvm-project#90152 and ROCm/rocThrust#404. I've implemented a fix downstream here: ROCm/rocThrust#405.
How to Reproduce
thrust::optional<int&>
(or any other optional holding a reference).emplace()
methodExpected behavior
From the implementation of the other operations in
thrust::optional<T&>
, it seems thatemplace()
onoptional<T&>
should replace the optional's value with the address of the operand, to construct a newT&
, rather than try to construct a newT
.Reproduction link
https://godbolt.org/z/359cvPso1
Operating System
No response
nvidia-smi output
No response
NVCC version
No response
The text was updated successfully, but these errors were encountered: