Skip to content

Commit 1070d6c

Browse files
author
Ivan Karachun
authored
[SYCL] Fixed check for set_arg (#2203)
Need to get rid of CV-qualifiers and references before checking for is_trivially_copyable and is_standard_layout. Signed-off-by: Ivan Karachun <ivan.karachun@intel.com>
1 parent 253a018 commit 1070d6c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

sycl/include/CL/sycl/handler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,9 @@ class __SYCL_EXPORT handler {
805805

806806
template <typename T> struct ShouldEnableSetArg {
807807
static constexpr bool value =
808-
std::is_trivially_copyable<T>::value
808+
std::is_trivially_copyable<detail::remove_reference_t<T>>::value
809809
#if CL_SYCL_LANGUAGE_VERSION && CL_SYCL_LANGUAGE_VERSION <= 121
810-
&& std::is_standard_layout<T>::value
810+
&& std::is_standard_layout<detail::remove_reference_t<T>>::value
811811
#endif
812812
|| is_same_type<sampler, T>::value // Sampler
813813
|| (!is_same_type<cl_mem, T>::value &&

sycl/test/basic_tests/set_arg_error.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,23 @@ int main() {
3333
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
3434
cl::sycl::access::target::local>
3535
local_acc({size}, h);
36+
TriviallyCopyable tc{1, 2};
37+
NonTriviallyCopyable ntc;
3638
h.set_arg(0, local_acc);
3739
h.set_arg(1, global_acc);
3840
h.set_arg(2, samp);
39-
h.set_arg(3, TriviallyCopyable{});
41+
h.set_arg(3, tc);
42+
h.set_arg(4, TriviallyCopyable{});
43+
h.set_arg( // expected-error {{no matching member function for call to 'set_arg'}}
44+
5, ntc);
4045
h.set_arg( // expected-error {{no matching member function for call to 'set_arg'}}
4146
4, NonTriviallyCopyable{});
4247
#if CL_SYCL_LANGUAGE_VERSION && CL_SYCL_LANGUAGE_VERSION <= 121
48+
NonStdLayout nstd;
49+
h.set_arg( // expected-error {{no matching member function for call to 'set_arg'}}
50+
6, nstd);
4351
h.set_arg( // expected-error {{no matching member function for call to 'set_arg'}}
44-
5, NonStdLayout{});
52+
7, NonStdLayout{});
4553
#endif
4654
});
4755
}

0 commit comments

Comments
 (0)