<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62006>62006</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
std::vector rotate crash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
devilsclaw
</td>
</tr>
</table>
<pre>
The crash only happens on windows and not in Linux and I have tested it on an online compiler as well.
The below code is just moving an item from one index position to another and it crashes
If I am doing something wrong let me know but it would be weird that it works everywhere else but the windows builds
Toolchains tested in windows are:
llvm-mingw-20220323-msvcrt-i686
llvm-mingw-20230320-msvcrt-i686
llvm-mingw-20230320-msvcrt-x86_64
my target app is 32bit due to dependencies but it currently can be build for 64bit to test.
```
#include <cstdio>
#include <cstring>
#include <string>
template<typename T>
void set_zorder(std::vector<T> v, T id, int index) {
if(index >= v.size()) {
return;
}
auto it = std::find(v.begin(), v.end(), id);
if(it != v.end()) {
std::rotate(it, it + 1, v.begin() + 1 + index);
}
}
int main(int argc, char** argv) {
std::vector<int> values = {1, 2, 3, 4, 5, 6, 7, 8, 9 , 10};
printf("BEFORE: = { ");
for(auto value : values) {
printf("%i, ", value);
}
printf("}\n");
set_zorder<int>(values, 9, 0);
printf("AFTER : = { ");
for(auto value : values) {
printf("%i, ", value);
}
printf("}\n");
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VcGOozgQ_RrnUurIGELIgUM66UgtrbTSqO8jgwvwjLGRbaAzX7-ySTLpTPdhpV0pqhi76tWrV4XhzslWI5Zk80w2xxUffWdsKXCSytWKz6vKiHP51iHUlrsOjFZn6PgwoHZgNMxSCzM74FqANh6khr-kHt_jxit0fELw6DwKkD4EcB0wpEaoTT9IhRa4gxmVWhN6JHS_2JCxQmVmqI1AkA5-jM5Dbyap2wAiPfbQWNOD0QhSC3yHwTjppdHgDXBtfBfAdcwc2aO7T_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