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
[SYCL] Use SFINAE to reject wrong signature of CGF object parameter (#11157)
For a mistake like this:
```
q.submit([&](sycl::handler cgh) { // Missing "&"
cgh.single_task([=]() {});
}).wait_and_throw();
```
changes errors from
```
In file included from <...>/build/bin/../include/sycl/sycl.hpp:16:
In file included from <...>/build/bin/../include/sycl/backend.hpp:34:
<...>/build/bin/../include/sycl/queue.hpp:361:18: error:
no matching member function for call to 'submit_impl'
361 | auto Event = submit_impl(CGF, CodeLoc);
| ^~~~~~~~~~~
a.cpp:5:5: note: in instantiation of function template
specialization 'sycl::queue::submit<(lambda at a.cpp:5:12)>' requested here
5 | q.submit([&](sycl::handler cgh) {
| ^
<...>/build/bin/../include/sycl/queue.hpp:2811:9: note:
candidate function not viable: no known conversion from '(lambda at a.cpp:5:12)'
to 'std::function<void (handler &)>' for 1st argument
2811 | event submit_impl(std::function<void(handler &)> CGH,
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<...>/build/bin/../include/sycl/queue.hpp:2814:9: note:
candidate function not viable: requires 3 arguments, but 2 were provided
2814 | event submit_impl(std::function<void(handler &)> CGH, queue secondQueue,
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2815 | const detail::code_location &CodeLoc);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```
to
```
a.cpp:5:5: error: no matching member function for call to 'submit'
5 | q.submit([&](sycl::handler cgh) {
| ~~^~~~~~
<...>/build/bin/../include/sycl/queue.hpp:344:3: note: candidate template ignored: requirement 'std::is_convertible_v<(lambda at
a.cpp:5:12), std::function<void (sycl::handler &)>>' was not satisfied [with T = (lambda at a.cpp:5:12)]
344 | submit(T CGF, const detail::code_location &CodeLoc =
| ^
<...>/build/bin/../include/sycl/queue.hpp:382:3: note: candidate function template not viable: requires at least 2 arguments, but 1 was
provided
382 | submit(
| ^
383 | T CGF, queue &SecondaryQueue,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384 | const detail::code_location &CodeLoc = detail::code_location::current()) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```
0 commit comments