Skip to content

Conversation

uditagarwal97
Copy link
Contributor

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.

@uditagarwal97 uditagarwal97 self-assigned this Aug 27, 2025
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner August 27, 2025 03:27
@uditagarwal97
Copy link
Contributor Author

Note to reviewers: This error can be reproduced with an existing E2E test, Basic/std_array.cpp, with the right MSVC version. That's why I didn't added any new test for this change.

@@ -36,6 +36,14 @@ extern "C" inline void __cdecl _invalid_parameter(wchar_t const *,
// Do nothing when called in device code
}

extern "C" __declspec(noreturn) void __cdecl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the comment at line 22?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reworked the entire comment. Hopefully, it is succinct and clear now.

@uditagarwal97 uditagarwal97 merged commit 1d3074d into sycl Aug 28, 2025
27 checks passed
@uditagarwal97 uditagarwal97 deleted the private/udit/invoke_watson branch August 28, 2025 00:17
AlexeySachkov pushed a commit to AlexeySachkov/llvm that referenced this pull request Sep 4, 2025
**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.
AlexeySachkov added a commit that referenced this pull request Sep 8, 2025
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.

Patch-by: Udit Kumar Agarwal <udit.agarwal@intel.com>
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