Skip to content

Conversation

AlexeySachkov
Copy link
Contributor

This is a cherry-pick of #19897

Problem
Basic/std_array.cpp fails to compile with MSVC 19.44.35207.1 with the following error

$ ./clang-cl.exe -fsycl -D_DEBUG -fsycl-device-only ./sycl/test-e2e/Basic/std_array.cpp /Od /MDd /Zi /EHsc
In file included from ../../sycl/test-e2e/Basic/std_array.cpp:8:
In file included from D:\iusers\uagarwal\llvm\build\bin\..\include\sycl/queue.hpp:12:
In file included from D:\iusers\uagarwal\llvm\build\bin\..\include\sycl/accessor.hpp:12:
In file included from D:\iusers\uagarwal\llvm\build\bin\..\include\sycl/buffer.hpp:14:
In file included from D:\iusers\uagarwal\llvm\build\bin\..\include\sycl/detail/common.hpp:17:
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\array(531,9): error: SYCL kernel cannot call an undefined
      function without SYCL_EXTERNAL attribute
  531 |         _STL_VERIFY(_Pos < _Size, "array subscript out of range");
      |         ^
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\yvals.h(259,9): note: expanded from macro '_STL_VERIFY'
  259 |         _STL_REPORT_ERROR(mesg); \
      |         ^
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\yvals.h(255,5): note: expanded from macro '_STL_REPORT_ERROR'
  255 |     _MSVC_STL_DOOM_FUNCTION(mesg)
      |     ^
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\yvals.h(249,41): note: expanded from macro
      '_MSVC_STL_DOOM_FUNCTION'
  249 | #define _MSVC_STL_DOOM_FUNCTION(mesg) ::_invoke_watson(nullptr, nullptr, nullptr, 0, 0)
      |                                         ^
c:/Program files (x86)/Windows Kits/10/include/10.0.26100.0/ucrt\corecrt.h(375,23): note: '_invoke_watson' declared here
  375 | _ACRTIMP void __cdecl _invoke_watson(
      |                       ^
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\array(529,39): note: called by 'operator[]'
  529 |     _NODISCARD _CONSTEXPR17 reference operator[](_In_range_(<, _Size) size_type _Pos) noexcept /* strengthened */ {
      |                                       ^
1 error generated.

Solution
Similar to what we did for _invalid_parameter
(#18400), mock _invoke_watson in corecrt STL wrapper.

**Problem**
`Basic/std_array.cpp` fails to compile with MSVC 19.44.35207.1 with the
following error
```
$ ./clang-cl.exe -fsycl -D_DEBUG -fsycl-device-only ./sycl/test-e2e/Basic/std_array.cpp /Od /MDd /Zi /EHsc
In file included from ../../sycl/test-e2e/Basic/std_array.cpp:8:
In file included from D:\iusers\uagarwal\llvm\build\bin\..\include\sycl/queue.hpp:12:
In file included from D:\iusers\uagarwal\llvm\build\bin\..\include\sycl/accessor.hpp:12:
In file included from D:\iusers\uagarwal\llvm\build\bin\..\include\sycl/buffer.hpp:14:
In file included from D:\iusers\uagarwal\llvm\build\bin\..\include\sycl/detail/common.hpp:17:
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\array(531,9): error: SYCL kernel cannot call an undefined
      function without SYCL_EXTERNAL attribute
  531 |         _STL_VERIFY(_Pos < _Size, "array subscript out of range");
      |         ^
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\yvals.h(259,9): note: expanded from macro '_STL_VERIFY'
  259 |         _STL_REPORT_ERROR(mesg); \
      |         ^
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\yvals.h(255,5): note: expanded from macro '_STL_REPORT_ERROR'
  255 |     _MSVC_STL_DOOM_FUNCTION(mesg)
      |     ^
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\yvals.h(249,41): note: expanded from macro
      '_MSVC_STL_DOOM_FUNCTION'
  249 | #define _MSVC_STL_DOOM_FUNCTION(mesg) ::_invoke_watson(nullptr, nullptr, nullptr, 0, 0)
      |                                         ^
c:/Program files (x86)/Windows Kits/10/include/10.0.26100.0/ucrt\corecrt.h(375,23): note: '_invoke_watson' declared here
  375 | _ACRTIMP void __cdecl _invoke_watson(
      |                       ^
c:/Program files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.44.35207/include\array(529,39): note: called by 'operator[]'
  529 |     _NODISCARD _CONSTEXPR17 reference operator[](_In_range_(<, _Size) size_type _Pos) noexcept /* strengthened */ {
      |                                       ^
1 error generated.
```

**Solution**
Similar to what we did for `_invalid_parameter`
(intel#18400), mock `_invoke_watson` in
corecrt STL wrapper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants