forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Fix ambiguity for bit_cast (intel#9398)
After merging kokkos/kokkos@ab41ef8 which implements `Kokkos::bit_cast`, we (@dalg24 and me) are seeing ambiguous calls to `bit_cast` originating from calls from https://github.com/intel/llvm/blob/28113ec691679dc0316a54c0da453014ff68a2c3/sycl/include/sycl/detail/spirv.hpp#L926-L937. The call to `bit_cast` there is unqualified, and passes an object in the `Kokkos` namespace which means that ADL kicks in. The compiler then finds both Kokkos::bit_cast and sycl::bit_cast. This problem was likely introduced by intel@d4b66bd#diff-dad3832b9c0831f4d9d2fa5695efc8c44f58d3fb0c97716af6bfd4eea882eb2fR631. To fix it, the calls should be qualified as proposed in the first commit. While working on a workaround in `Kokkos`, I also noticed that `sycl::bit_cast` is unconstrained and always participates in overload resolution although `std::bit_cast` should only participate in overload resolution only if `sizeof(To) == sizeof(From)` and both `To` and `From` are [TriviallyCopyable](https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable) types, see, e.g., https://en.cppreference.com/w/cpp/numeric/bit_cast. Thus, the second commit moves the `static_assert`s to template constraints in terms of SFINAE.
- Loading branch information
1 parent
fb38046
commit 834df47
Showing
3 changed files
with
24 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters