Skip to content

Commit ecd0adb

Browse files
authored
[SYCL] Fix compilation with --std=c++20 (#2705)
- add include containing definition of std::bit_cast - replace usage of share_pointer::unique() deprecated in C++20 - add test to verify compilation with different C++ standards
1 parent f422393 commit ecd0adb

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

sycl/include/CL/sycl/detail/helpers.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
#include <CL/sycl/detail/pi.hpp>
1717
#include <CL/sycl/detail/type_traits.hpp>
1818

19+
#if __cpp_lib_bit_cast
20+
#include <bit>
21+
#endif
1922
#include <memory>
20-
#include <numeric> // std::bit_cast
2123
#include <stdexcept>
2224
#include <type_traits>
2325
#include <vector>

sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
150150

151151
__SYCL_DLL_LOCAL void set_final_data_from_storage() {
152152
MUploadDataFunctor = [this]() {
153-
if (!MSharedPtrStorage.unique()) {
153+
if (MSharedPtrStorage.use_count() > 1) {
154154
void *FinalData = const_cast<void *>(MSharedPtrStorage.get());
155155
updateHostMemory(FinalData);
156156
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -c -o %t.out
2+
// RUN: %clangxx -std=c++14 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
3+
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
4+
// RUN: %clangxx -std=c++20 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
5+
// expected-no-diagnostics
6+
7+
#include <CL/sycl.hpp>

0 commit comments

Comments
 (0)