Commit ed77f66
Disable MSVC debug assertions, addressing false positives in iterator checking (#1952)
This PR aims to suppress an msvc debug assertion that has been
identified as a false positive. The debug scenario is illustrated in the
image below
<img
src="https://github.com/user-attachments/assets/b12fdf10-f4a6-4010-a73b-20ff0a2bbf14"
alt="debug_assert" width="300"/>
<img
src="https://github.com/user-attachments/assets/c499e33d-630e-4e0d-855e-9e9799fc6ba8"
alt="genai_debug" width="500"/>
This line of code triggered an MSVC false positive assertion. Please
refer to
https://github.com/microsoft/STL/blob/1f6e5b16ec02216665624c1e762f3732605cf2b4/stl/inc/vector#L122
The simplest reproducer: The following code triggers the assertion when
debugging in Visual Studio 2022
```C++
// command line : cl.exe /Zi /EHsc /std:c++17 /Od /MDd main.cpp
#include <iostream>
#include <vector>
int main()
{
std::vector<int64_t> content, m_generated_ids{ 1 }, prompt_ids(24);
size_t start = 0, content_length = 25;
content.insert(content.end(), m_generated_ids.begin() + start, m_generated_ids.begin() + content_length - prompt_ids.size());
std::cout << "Succeed!";
}
```
Another way to suppress the assertion is by adding
`/D_ITERATOR_DEBUG_LEVEL=0`. I'm not sure whether modifying the code or
adjusting the compiler option is better.
Co-authored-by: Ilya Lavrenov <[email protected]>1 parent fa479b8 commit ed77f66
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
0 commit comments