<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62005>62005</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/eJy0VcGO4jgQ_RpzKTUyDgnhwIGGRmpppZVGfR-ZuEg849iR7STNfP2qHGBopvuw0u6l4thVr169qjgyBF1bxA3Ln1m-n8k-Ns5vFA7ahMrIcXZ06rx5axAqL0MDzpozNLLr0AZwFkZtlRsDSKvAugjawl_a9u9p4xUaOSBEDBEV6EgB0hKGtgiVaztt0IMMMKIxc8b3jG8nSxmPaNwIlVMIOsCPPkRo3aBtTSA6Ygsn71pwFkFbhe_QuaCjdhaiA2ldbAjcpsyJP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